Skip to content

[AI-3551][AI-3552] Imported connector definitions get the API's limits - #2430

Merged
kanat merged 12 commits into
mainfrom
kanat/ai-3551-import-connector-limits
Nov 25, 2026
Merged

kanat merged 12 commits into
mainfrom
kanat/ai-3551-import-connector-limits

Conversation

@kanat

@kanat kanat commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Why

A custom connector created through the API is held to its request schema's limits (id pattern, lengths, scope tokens). A definition that arrives through a data move (POST /v1/data/import, router replicate) was held only to the shared manifest rules, so it could store a definition the API refuses, such as one with an over-long name (AI-3551). And an old custom definition with oauth2_client_credentials, which custom connectors lost in #1925, stopped the whole move with a 400, though no connection could ever use it (AI-3552).

How it works

an imported connector_definitions row (export line or change)
├─ schemes hold oauth2_client_credentials? (store.SkippedRow)
│   └─ yes -> not written; named as connector_definitions:{"id":..,"revision":..}
│        ├─ POST /v1/data/import -> "skipped": [...] in the answer
│        └─ router replicate      -> one Warn log line per row
└─ no -> importableDefinition
     ├─ Manifest.AsCustom -> core.CustomManifest -> checkLimits   (400 naming the id)
     ├─ sync_hash: printable ASCII, <= 128                      (400 naming the id)
     └─ name / category / description columns := the checked manifest's

One place for the limits:

core (custom.go)          CustomIDPattern, CustomNameMaxLength, ... ScopeTokenPattern
store (connector_definition.go)  SyncHashMaxLength, SyncHashPattern
   │                                   │
   ├─ CustomManifest.checkLimits ──────┤── importableDefinition (import)
   └─ CustomConnectorRequest.TransformSchema (API schema; openapi.yaml unchanged for it)
Limit API before Import before Import now Test
id ^custom_[a-z][a-z0-9_]{0,56}$ schema custom_ prefix + identifier refused TestAnIDIsCustomThenALetterThenUpTo56More
name 120 / category 80 / description 1000 / endpoint 2048 chars schema none refused TestANameIsAtMost120Characters and siblings
scopes: at most 100, each an RFC 6749 scope-token, no repeats schema none refused TestAScopeIsAnRFC6749ScopeToken, TestAConnectorAsksForAtMost100Scopes, TestAScopeListedTwiceIsRefused
sync_hash: printable ASCII, 128 schema none refused TestAnImportedDefinitionsSyncHashIsPrintableASCIIOfAtMost128
row's name/category/description columns written from the manifest as the file said written from the manifest TestAnImportedDefinitionsColumnsAreItsManifests
oauth2_client_credentials definition refused 400, move stops skipped and named TestAnImportSkipsAClientCredentialsDefinitionAndWritesTheRest, TestAChangePageWithAClientCredentialsDefinitionAppliesTheRest, TestAnImportNamesTheClientCredentialsDefinitionsItLeftOut, TestAReplicateLeavesOutAClientCredentialsDefinitionAndSaysWhich

The endpoint's DNS check stays out of the import: a definition whose host stopped resolving would stop the whole move, and every connection still dials only a public address (internal/connectors/core/transport.go:102, egress.NewClient).

Changes

  • core.CustomManifest checks the limits, so both the API and Manifest.AsCustom (the import) apply them. CustomConnectorRequest writes the same values into its schema; the rendered CustomConnectorRequest in openapi.yaml is byte-for-byte the same.
  • DataImport gets an optional skipped list; clients regenerated (Python, JS, Go, Ruby, .NET, Rust, PHP changed; Kotlin, Dart and Swift --check unchanged, since the operation is server-side).
  • Data move docs (acceleration/README.md) say what happens to such a definition.
  • Test ids for imported definitions now start with a letter (custom_a + hex): a hex id may start with a digit, which the API never allowed.

🤖 Generated with Claude Code

kanat and others added 5 commits November 24, 2026 23:25
…s; a client-credentials one is skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…definition

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…; regenerate the clients

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efinition and logs it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[security R1] NO-GO: 1 Should fix, 2 Nits.

  • S1.1 (Should fix): the client-credentials skip runs before the imported definition's id is checked, so a row the import refused before for another reason (a built-in or malformed id) is now accepted as skipped, and its unchecked id and revision are kept and echoed in skipped for the whole body. Fix inline. The regression tests come with the fix.
  • S1.2 (Nit): the skipped list has no bound.
  • S1.3 (Nit): a delete change can be reported as skipped although it ran.

Checked and fine: the API's create/update limits are not wider (the spec for the request is unchanged, Huma recompiles patterns after TransformSchema, and each limit is still refused over the API with the at-limit value accepted). The new error texts are the router's own. The key holds only id and revision, never manifest, endpoint or client fields. The import makes no DNS lookup, and dials stay on the public-only egress dialer. 5 of the PR's guards were mutation-checked on the head merged onto current main: all 5 killed.

Author questions: dropping a definition that lists client credentials next to a usable scheme fails closed, so it has no security effect either way (product call). The sibling copies of the numbers only narrow, so they can be a ticket. Leaving the DNS check out of the import is fine.

Comment thread acceleration/internal/store/datamove.go Resolved
Comment thread acceleration/internal/api/datamove.go Resolved
Comment thread acceleration/internal/api/datamove.go Resolved

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: NO-GO

Round-1 review of 5cd13a9 merged onto main (015271b, clean; main has since gained one commit that touches only internal/session). This is a draft, so no CI ran. CI runs at gh pr ready.

Hard rule, checked base against head:

  • An import of definitions made through the API stores the same rows as on base. A probe made 3 definitions through CustomManifest + ReviseSynced, 2 revisions each, at every limit, moved them, and dumped the destination rows. The output is the same on base and head.
  • A create through the API answers the same as on base. A probe sent 24 bodies at and past each limit (id, name, category, description, endpoint, scope count, scope token, sync hash, client credentials). Status and message are the same on base and head.

Blocking: the security review's S1.1 (a client-credentials row is skipped before its id is checked) is confirmed: SkippedRow names a row with id github or id 12, which importableDefinition refuses. I do not file it again. With R1.1 below, the verdict is NO-GO.

Question R1.2 (no diff line, ticket): a connection that uses a skipped definition revision is still imported. Nothing references that revision any more, and skipped does not name the connection. Nothing fails, because no foreign key points at connector_definitions and the readers tolerate a missing revision (Statuses, revocableGrants). Decide whether skipped should name such connections too.

Checked and sound:

  • The id pattern has been on the API since #727, and only the API writes custom definitions. So only rows written by an earlier import can hold an id the import now refuses.
  • When a skipped row is later updated, the update is skipped too. When it is later deleted, the delete changes nothing and does not fail.
  • skipped is additive for old clients (Python keeps additional properties; Rust's DataImport does not deny unknown fields).
  • Only generated models changed, no hand-written SDK code, so no SDK note is needed.
  • generated.sh: in step.
  • Suites pass on the merged tree: unit (api, store, core, cmd/router), store TestDataMoveSuite, router TestReplicateIDsSuite and TestReplicateResumeSuite.
  • 11 more mutants: 1 survived (R1.1), 1 is equivalent.

Comment thread acceleration/cmd/router/replicate.go Resolved
kanat and others added 5 commits November 25, 2026 00:26
…I could have stored

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…counts only copied rows

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t; a delete leaves none out

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…data move docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: GO

Delta round 2 on 30e50ec (previous reviewed 5cd13a9). Ran the suites and probes the first delta reviewer could not run. Details: AI-3551 ledger reviewer-2b.md.

Prior findings

  • S1.1 fixed. SkippedRow names a row only when the id is a string matching core.CustomIDPattern and the revision an integer >= 1. Probes on this head: a client-credentials row with id github is a 400; 8 such rows with 1 MiB ids are a 400, no longer a 200 holding 8 MiB. Unit mutants (id pattern, revision, revision < 0) fail the unit test.
  • S1.2 fixed. The answer names 100 rows and counts the rest in skipped_more. Mutants (no cap, cap 101, rest not counted) are all killed by TestAnImportNamesAtMostAHundredOfTheRowsItLeftOut.
  • S1.3 fixed at both sites. Api import: Op != ChangeDelete forced true is killed by TestADeleteThatCarriesAClientCredentialsDefinitionLeftNothingOut. Replicate follow: if false instead of the delete check is killed by TestAReplicateLeavesOutAClientCredentialsDefinitionAndSaysWhich.
  • R1.1 fixed. Removing the continue in copyEverything is killed by the same replicate test (it now requires rows == 1).
  • R1.2 stays a ticket (a connection that uses a skipped revision is not named), as agreed.

Runs (head alone, not merged with main; DB model_router_test_hr3551b_test)

  • store TestDataMoveSuite: ok. cmd/router TestReplicateIDsSuite (15 tests, the skip test among them): ok. api TestPostureSuite: ok. Core and store unit tests: ok.
  • api TestDataMoveSuite: all pass except TestAnImportLineJustUnderTheLimitIsRead (500, write tcp ...: i/o timeout writing a 64 MiB row to Postgres, machine load 60-80). The same test fails 3 of 3 reruns on base 0e5197a and 5 of 5 on head. A 64 MiB agent_configs row never reaches this PR's code, so it is the environment, not the delta. CI will tell.
  • Round-1 probes (24 create-limit cases, 6 imports of API-made definitions) give output identical to round 1.
  • gh pr checks: draft; CodeQL, Analyze x3, GitGuardian, labeler pass; integration skipped (draft).

Needs a rebase before merge: origin/main is now b86e02f and git merge-tree shows a conflict in acceleration/internal/api/datamove.go (main's #2412 moved importData's state into a dataImport struct; three hunks). The resolution is new code this verdict does not cover. Re-run TestDataMoveSuite (api) after resolving.

New findings

  • [Nit] acceleration/internal/connectors/core/custom.go:61: the new id check puts the id in its message (id %q is not ...) and importableDefinition wraps it with %q again, so a rejected 1 MiB id comes back twice (2,097,543 bytes; base 1,048,979). Bounded by one id since the import stops at the first line, so not blocking. Fix: leave the id out of this message (the caller's wrapper already names it).

kanat and others added 2 commits November 25, 2026 08:48
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@kanat kanat left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: GO

Delta round 3, head 5259a4a (previous reviewed 30e50ec), merged onto origin/main 641ee30.

Merge of #2412 (api/datamove.go): git diff b86e02f87 HEAD shows only this PR's lines on top of #2412's file. #2412's dataImport struct, importLine deadline handling, NumbersLeftOutError (leftOut) on both paths and numbers_left_out in the log are kept. The skipped cap of 100, skipped_more, no name for deletes, and the skip in the row path are all in. No side was taken wholesale.

  • M2.1: fixed. The merge keeps #2412's structure and this PR's behaviour. A clean merge onto the current main was checked.
  • N2.1: fixed. The id is out of the check's message, and TestARefusedImportedIDIsInTheAnswerAtMostOnce pins one copy of a 1 MiB id. The mutant that puts the id back fails it.
  • Earlier S1.1-S1.3, R1.1 stay fixed. R1.2 stays a ticket.

Runs on the merged head: api TestDataMoveSuite (including TestAnImportLineJustUnderTheLimitIsRead), TestPostureSuite, store TestDataMoveSuite, cmd/router TestReplicateIDsSuite, core and store unit tests all pass. go vet is clean.
Mutations: 10 run, 0 survived (cap removed, cap 101, rest not counted, skipped_more not answered, delete named in api, delete logged in replicate, Change-path skip, row-path skip, replicate continue, N2.1).
No new findings. CI: draft; CodeQL, Analyze and GitGuardian pass, the rest skip.

@kanat
kanat marked this pull request as ready for review November 25, 2026 14:15
@kanat
kanat merged commit 2ade1ba into main Nov 25, 2026
28 checks passed
@kanat
kanat deleted the kanat/ai-3551-import-connector-limits branch November 25, 2026 15:28
kanat added a commit that referenced this pull request Nov 25, 2026
Conflicts:
- internal/api/connectors.go: main's #2430 moved CustomConnectorRequest's limits into
  TransformSchema (core.Custom* constants); kept that, with the feature's optional endpoint
  and http field.
- internal/store/datamove.go: the feature checks a definition in importableRow, before
  importRow and outside applyChanges' transaction; main's #2430 SkippedRow (a
  client-credentials definition is left out) now passes such a row unchecked there and
  importRow leaves it out. ImportRow's err from importableRow is reused by main's #2446
  detachedWrite.
- internal/api/datamove_test.go, core/custom_test.go, store/datamove_unit_test.go: both
  sides' tests kept; main's importableDefinition calls take the feature's ctx.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat added a commit that referenced this pull request Nov 25, 2026
- An http tool's description and path caps are core's CustomDescriptionMaxLength and
  CustomEndpointMaxLength, which #2430 made the one home of those values, rather than 1000
  and 2048 written again.
- The feature's import tests name their definitions custom_a + a hex id: #2430 holds an
  imported id to the API's pattern, a letter after custom_, which a hex id need not start
  with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat added a commit that referenced this pull request Nov 26, 2026
Feature branch for [AI-3669](https://linear.app/stream/issue/AI-3669):
the router gets an `http` tool source. A file
`connectors/http/<name>.yaml` names a public https base URL and
read-only tools. Once synced, an agent calls those tools with a user's
credential.

## What it does

```
connectors/http/<name>.yaml
  │  CLI sync
  v
POST /v1/agents/connectors   (http block)
  │
  v
manifest, sources/http
  │  agent session offers the tool
  v
session tool call -> base_url + path, with the connection's credential
```

Safety rules. Each is checked when the connector is saved, at each call,
or both:

| Rule | Effect | Checked |
|---|---|---|
| Public https only | `base_url` goes through the egress check; private
and plain-http hosts are refused | save (`CheckBaseURL`), and every
call, as the connection's client is the egress client |
| `read_only` GET and HEAD | other methods are refused on `read_only`
tools | save. A tool whose definition changed since its grant is not
offered (the grant pins a digest of method, path and `read_only`) |
| Override args refused | the model cannot change the method, host or
headers | save refuses a parameter or header named like a method
override; a call refuses an argument the tool does not declare, before
anything is sent |
| Path segments escaped | `..%2Fadmin` stays one segment | every call |
| Size caps | 4 MiB read from the provider, 32 KiB to the model (with a
marker) | every call |
| Egress limits | the same egress client and the same 4 MiB read cap as
the MCP source, and #2430's import limits | every call; import |

## Pieces

All merged into this branch, each reviewed on its own PR. Three commits
on the branch itself follow the last main sync: the feature's caps
become core's after #2430, a subtest split of #2480's test, and a test
that an http custom connector meets an MCP one's limits.

| Piece | Ticket | PR | Merge commit |
|---|---|---|---|
| Manifest model for http tools | AI-3673 |
[#2303](#2303) | 7d1d6b7 |
| `sources/http` tool source | AI-3674 |
[#2316](#2316) | 2a29dac |
| Call-time safety | AI-3675 |
[#2324](#2324) | 5a798ad |
| API accepts http connectors (keystone) | AI-3676 |
[#2344](#2344) | aed810a |
| A connector's answer names its source kind | AI-3871 |
[#2464](#2464) | c72f50f |
| Pin delegation's digest check; own SDK note | AI-3870 |
[#2480](#2480) | 73e80f2 |
| Fake provider's CodeQL alert; SDK skill names http connectors |
AI-3870 | [#2483](#2483) |
469960b |

Main was merged into the branch 9 times; the last is main `f58ff6eb3`.
An earlier one, main `c4119ba23`, carries
[#2430](#2430 import limits.
Imported http connectors are held to the same limits.

The merge of main `8232d25af` brings in two changes that touch http
connectors:
- [#2485](#2485) refuses
imported agent configs that break the sensitive-connector rule. An http
connector's tools are weighed by their own rule: a tool that is not
read-only, or a read-only tool granted without its digest, is refused. A
test covers this
(`TestAnImportedHTTPConnectorAnAgentBindsBesideASensitiveOneIsWeighedByItsTools`).
- [#2434](#2434) adds
`check_changes` to a custom connector create. An http connector takes
the same path as an MCP one, and a test covers the http case
(`TestACheckedSyncOfAnHTTPConnectorIsRefusedOnlyOverAnEditNoSyncWrote`).

## Acceptance

AC-1..AC-9 are frozen in the epic. The staging window was opened twice
on the branch build, then staging was restored.

| AC | Result | Checked |
|---|---|---|
| AC-1 | pass | staging windows 1 and 2 (router part). The CLI line
(first sync prints the connector id) is in
[GetStream/cli#128](GetStream/cli#128) |
| AC-2 | pass | staging window 1 and 2 |
| AC-3 | pass | staging window 1 and 2: one tool call, the agent
answered from it |
| AC-4 | pass | staging window 1 and 2 |
| AC-5 | pass | staging window 1 and 2 |
| AC-6 | pass | local router: override args refused, the fake provider
saw 0 requests |
| AC-7 | pass | staging, by API and by CLI |
| AC-8 | pass | staging window 1 and 2: a JSON body comes back as
`application/json` |
| AC-9 | pass | local router: 100 KiB cut to 32768 B with a marker, 5
MiB cut at the 4 MiB read cap |

Rulings by Kanat (2026-11-25):

- AC-4: the "no token" clause is read as a wrong token. A wrong token
gives a tool error 401. A connection with no token at all stays
`not_connected` and its tool is not offered, as before.
- AC-5: the CLI refuses a `read_only` POST or DELETE locally, before any
request. The router refuses the same with a 400 on a direct POST.

## Gates for the merge into main

| Gate | What |
|---|---|
| a | Done: [#2481](#2481)
merged into main (`96d535d9d`), which fixed main's integration build at
`scheduled_unpaid_test.go:814`. This branch builds and vets with the
integration tag merged onto main `aa4c2d4d9` |
| b | Full CI green once this PR leaves draft (a draft runs none of the
go or integration jobs) |
| c | [GetStream/cli#128](GetStream/cli#128)
merges after this is deployed, then the docs leaf AI-3678 |
| d | SDK releases that carry `Connector.sources` go out only after the
router deploy: the generated Python and Rust clients cannot parse a
connector from an older router |
| e | No migration, no flag. A rollback to the previous build fails
closed: an http binding is unavailable, and every http tool counts as
sending out |

## Breaking change

From `CHANGELOG.md` on the branch, under Unreleased, Breaking Changes:
**`CustomConnectorRequest`'s endpoint is optional in the Go, Rust, PHP
and Python SDKs**

- Go: `CustomConnectorRequest.Endpoint` is now `*string`. Set it with a
pointer (for example `Endpoint: &url`); a caller that set a plain string
no longer compiles.
- Rust: `CustomConnectorRequest.endpoint` is now `Option<String>`. Set
it with `Some(url)`; a struct literal with a plain `String`, or a read
of one, no longer compiles.
- PHP: the `CustomConnectorRequest` constructor takes `$endpoint` after
`$schemes`, not first. A positional call no longer matches; named
arguments work as before.
- Python (`plugins/stream`): the generated `CustomConnectorRequest`
takes `endpoint` after `schemes`, not first. A positional call no longer
matches; keyword arguments work as before.

## Rollout

```
merge this PR -> deploy to staging
  -> recheck AC-3 and AC-8 live -> merge cli#128 -> docs (AI-3678)
  -> SDK releases with Connector.sources
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant