Skip to content

fix(embed): Go router vs the real Monad API [PRO-456] - #18

Open
Credgate wants to merge 6 commits into
feature/pro-403from
feature/pro-456
Open

fix(embed): Go router vs the real Monad API [PRO-456]#18
Credgate wants to merge 6 commits into
feature/pro-403from
feature/pro-456

Conversation

@Credgate

@Credgate Credgate commented Aug 4, 2026

Copy link
Copy Markdown

Addresses the CHANGES_REQUESTED review on #15. Eight of the ten comments were accurate, and three are live bugs rather than style nits. Every item was validated against the API source in monad-inc/api, not the published spec — sdk/openapi.json is ~15 months stale and still marks UpdatePipelineRequest fields required.

Second of three stacked fix PRs. Stacked on #17 (PRO-455) — it carries the mock changes this PR's conformance run depends on, so review/merge bottom-up. That's also why #17's commits appear in this diff; they drop out when it merges.

Linear: PRO-456

The three real bugs

Pipeline pagination. GET /v2/{org}/pipelines/ defaults to limit=10 (pipelines.go:727) and the router sent none. Past a tenant's tenth pipeline, GET /embed/pipelines reported hasPipeline: false for pipelines that exist.

setEnabled wiped graph fields. PATCH became a true partial update in api#2163 (your commit). The read-modify-write it replaces rebuilt the whole graph from a partial field list and sent it back, so every enable/disable silently dropped node config_overrides and edge schema_detection_spec. Now a one-line PATCH {"enabled": …}.

component_of. You were right that this already exists — GET /v1/{org}/{kind}s/{id} returns it unconditionally, no expand flag (organization_inputs.go:79,109-124). It replaces the whole N+1 scan and fixes the pagination bug at the same time: N+1 requests → 2.

The rest

type instead of the deprecated output_type (api#2156); exhaustive paging on the connector list; the speculative data/config fallbacks deleted (the list returns only {pipelines, pagination}, the detail is flat); a componentKind type with an explicit path mapping instead of kind + "s"; url.PathEscape inline instead of the esc alias — the escaping stays, it's a real boundary since connectorId comes from the browser.

On the unmarshal comment (client.go:147): that one was accurate against e287e687, but the later force-push had already rewritten it to map[string]json.RawMessage. No change needed — flagging so it doesn't read as ignored.

On the Next() pagination helper: kept internal rather than exposed. The /embed contract has no pagination at all (zero matches for limit|offset|cursor|page in embed.openapi.yaml), so a public paginated type would need a contract amendment across all three routers and the browser client. Callers still get complete lists.

Behavior change

An unknown connector id now returns 404 not_found rather than 200 {hasPipeline:false}, since resolution goes through a connector fetch.

Verification

go vet, gofmt, go test clean (8 new tests covering component_of resolution, the PATCH body, type on create, and page draining). Conformance ROUTER=go 35/35.

Not yet run: live mode. Three things the mock cannot settle and I'd want confirmed against staging before merge — (a) component_of is populated on real responses, (b) PATCH {"enabled":false} leaves nodes/edges/name intact on re-GET, (c) the real status code for an unknown connector id. responder.Error masks to 500 unless the error implements both ErrorCode and PublicError (responder.go:145-166), so the 404 mapping is inference, not verified fact.

…[PRO-455]

Review of the Go port (#15) surfaced defects the TypeScript reference has too.
Validated against the API source rather than the published spec, which is stale.

- resolve a connector's pipeline via `GET /v1/{org}/{kind}s/{id}`'s
  `component_of` instead of scanning every pipeline. The scan sent no `limit`,
  so past the tenant's tenth pipeline it reported "not connected" for pipelines
  that exist.
- `setEnabled` now PATCHes `{enabled}` alone. PATCH became a true partial update
  in api#2163; the read-modify-write it replaces silently dropped node
  `config_overrides` and edge `schema_detection_spec` on every toggle.
- drain the connector list instead of one `limit=1000` request
- send `type` on output create; `output_type` is deprecated (api#2156)
- drop the speculative `data` / `config` response-shape fallbacks — Monad
  returns neither
- map `kind` to its path segment explicitly rather than appending "s"
…of [PRO-455]

The mock returned every row regardless of `limit` and had no
`GET /v1/{org}/{kind}s/{id}` route at all, so it could not catch two bugs the
routers actually have: they never send `limit` (Monad defaults it to 10) and
they walk the whole pipeline list to answer a question `component_of` answers
in one call.

- page every list at Monad's default limit of 10, with no maximum
- serve the connector detail route, including `component_of` — pinned to the
  same narrow projection the datastore emits (no `status`, no `nodes`)
- accept `type` on output create, `output_type` staying a deprecated alias
- track connectors statefully so a delete is observable
- add the >10-pipelines scenario; it fails against the pre-fix routers
Addresses the review on #15. Each item was validated against the API source
rather than the published spec, which is ~15 months stale.

- resolve a connector's pipeline via `GET /v1/{org}/{kind}s/{id}`'s
  `component_of` instead of scanning every pipeline. The scan sent no `limit`,
  and Monad defaults it to 10 — past a tenant's tenth pipeline the router
  reported "not connected" for pipelines that exist. Also turns an O(n)
  request fan-out into two calls.
- `setEnabled` now PATCHes `{enabled}` alone. PATCH became a true partial
  update in api#2163; the read-modify-write it replaces rebuilt the whole graph
  from a partial field list, silently dropping node `config_overrides` and edge
  `schema_detection_spec` on every toggle.
- drain the connector list rather than one `limit=1000` request
- send `type` on output create; `output_type` is deprecated (api#2156)
- drop the speculative `data` / `config` response-shape fallbacks — the list
  returns only `{pipelines, pagination}` and the detail is flat
- `componentKind` type with an explicit path mapping, replacing `kind + "s"`
- inline `url.PathEscape` instead of the one-letter `esc` alias
- README: document `GetCustomerOrgID` as the tenant-isolation boundary
…[PRO-455]

Review of the Go port (#15) surfaced defects the TypeScript reference has too.
Validated against the API source rather than the published spec, which is stale.

- resolve a connector's pipeline via `GET /v1/{org}/{kind}s/{id}`'s
  `component_of` instead of scanning every pipeline. The scan sent no `limit`,
  so past the tenant's tenth pipeline it reported "not connected" for pipelines
  that exist.
- `setEnabled` now PATCHes `{enabled}` alone. PATCH became a true partial update
  in api#2163; the read-modify-write it replaces silently dropped node
  `config_overrides` and edge `schema_detection_spec` on every toggle.
- drain the connector list instead of one `limit=1000` request
- send `type` on output create; `output_type` is deprecated (api#2156)
- drop the speculative `data` / `config` response-shape fallbacks — Monad
  returns neither
- map `kind` to its path segment explicitly rather than appending "s"
# Conflicts:
#	routers/typescript/src/monad.ts
@Credgate
Credgate marked this pull request as draft August 4, 2026 17:10
@Credgate
Credgate marked this pull request as ready for review August 4, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant