test(table): pin the executor auth pairing on the table read route - #6603
Conversation
fetchTableSchema reaches GET /api/table/[tableId] with a legacy type:'internal' token, which only works while that route authenticates through checkSessionOrInternalAuth. Its sibling table routes already moved to the delegation policy, which rejects that token outright, so migrating this one without moving the caller in the same change would break every table tool on an Agent block. Assert the route still authenticates through the legacy path so that migration fails here first, and record on the caller why it is deliberately not on buildExecutorDelegationHeaders yet.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview The new test asserts Bearer tokens still go through the legacy verifier that accepts Reviewed by Cursor Bugbot for commit 2c3fc06. Configure here. |
Greptile SummaryThe PR documents the intentional legacy authentication pairing used by
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/table/[tableId]/route.test.ts | Adds an effective regression test that pins the route’s legacy verifier choice and confirms the Bearer header reaches it unchanged. |
| apps/sim/tools/schema-enrichers.ts | Adds documentation explaining the intentional dependency between fetchTableSchema and the table GET route’s existing authentication path. |
Reviews (2): Last reviewed commit: "test(table): assert the Bearer header re..." | Re-trigger Greptile
Address review: the pairing test sent no Authorization header and its name claimed to verify token acceptance, which is pinned separately in lib/auth/internal.test.ts. Send a representative header, assert it reaches checkSessionOrInternalAuth unmodified, and scope the name and docs to what this guard actually covers — the route's choice of verifier.
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2c3fc06. Configure here.
Summary
Follow-up to #6593.
fetchTableSchemais the last enricher still calling the deprecatedbuildAuthHeaders, and after #6593 migrated its two siblings in the same file it now reads like a missed migration. It isn't — and "fixing" it today would break table tools.GET /api/table/[tableId]authenticates throughcheckSessionOrInternalAuth→verifyInternalToken, which requirestype: 'internal'. An executor delegation carriestype: 'internal_delegation'and is rejected, then falls through to session auth the executor doesn't have.[tableId]/groups,[tableId]/exports,imports/*) are already oninternalTableSessionOrExecutorAuth, so this route is the straggler and a plausible next migration target.tables.readalso declaresdelegatedServices: ['copilot'], so an executor delegation would be refused at the operation layer even if the route accepted it.So: assert the route still authenticates through the legacy path, and record on the caller why it is deliberately not migrated. The migration that flips this route now fails on a test that names the caller, instead of shipping and breaking table tools.
Why not migrate the route here
readTableUseCaseexists, but this GET returns an 18-field payload includingmaxRowsfromgetWorkspaceTableLimits, which the use case does not supply, and the response is consumed by the Tables UI. Doing it properly means a new contract matched field-by-field against the current output plus wideningtables.read's principal policy — a scoped migration of its own, not a follow-up rider on something that isn't broken.Correction to how this was previously described
I earlier called this a latent copy of the #6593 bug. The auth coupling is the same; the failure mode is the opposite.
enrichTableToolSchemais wired as a tool-leveltoolEnrichment, andcreateLLMToolSchemawraps those inToolSchemaEnrichmentErrornaming the tool — so a break here fails the Agent block loudly rather than silently degrading the schema the way the workflow and knowledge enrichers did. That is why this is a guard rather than a fix.Type of Change
Testing
checkSessionOrInternalAuthcall and the new test failed while the existing PATCH tests stayed green, so it is targeted rather than incidental.bunx vitest run app/api/table/ tools/— 2,746 passing.lint:check,type-check, andcheck:api-validation.Checklist