Repository navigation
fix(service-datasource)!: external validate answers an unknown datasource 404 RESOURCE_NOT_FOUND - #27911
Conversation
…rce 404 validateDatasource(name) returned an empty, vacuously ok report for a name no saved datasource has, so POST /api/v1/datasources/:name/external/validate answered 200 where GET /datasources/:name and the other federation doors answer 404 RESOURCE_NOT_FOUND. It now checks existence first, as testConnection does, and throws the package's one datasourceNotFoundError before anything is listed or introspected; the route relays it as such. A saved datasource with nothing federated, and the primary one, keep their 200 empty report. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cx56cEs32AZSfABRR8
📓 Docs Drift CheckThis PR changes 2 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 4 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 9cc0a504c8fe68720d4a2f7a863871b865a297a7 && git checkout 9cc0a504c8fe68720d4a2f7a863871b865a297a7
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d770b1505e5b172c5a0cea2c22878067da2966b2 bdbdaae521a95b8baf08e553ac499060b3ccd2d0 && git checkout -B drift-repro d770b1505e5b172c5a0cea2c22878067da2966b2 && git merge --no-ff bdbdaae521a95b8baf08e553ac499060b3ccd2d0
node scripts/docs-audit/affected-docs.mjs --json d770b1505e5b172c5a0cea2c22878067da2966b2
|
|
domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia Contract-review-claim: The lane seat runs the |
|
domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS |
|
domain:server#3 · os-elon-musk · session_016WV4czuTWNgKR22fKv7jia Seat ACCEPT · PR #27911 · head
|
Requested by Elon · project thread
Fixes #27696
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no
skills/**file or authored doc teaches what validate answers for an unknown name (git grep "external/validate" -- skills content docshits only release notes and QA checklist items about the auth floor and the in-sync report)BREAKING for a caller of
POST /api/v1/datasources/:name/external/validate, or ofExternalDatasourceService.validateDatasource, that addresses a datasource name that does not exist:200 { ok: true, results: [] }becomes404 RESOURCE_NOT_FOUND. The changeset carries the before / now / fix and its ADR-0087 marker (not-required (no-migration-prescription)).维护者速读
POST /datasources/NAME/external/validate遇到不存在的数据源名时,改为返回 404「数据源不存在」,与查看数据源和其它联邦接口一致。packages/services/service-datasource/src/external-datasource-service.ts的validateDatasource开头三行;再看packages/rest/src/external-datasource-unknown-name.test.ts新增的三个用例。pnpm --filter @objectstack/rest exec vitest run src/external-datasource-unknown-name.test.ts,预期 15 个用例全绿,其中未知名字 404、warehouse与default仍 200 空报告。What changes
ExternalDatasourceService.validateDatasource(name)(service-datasource) now checks the datasource exists before anything is listed or introspected, the same checktestConnectionmakes (datasources: POST /datasources/NAME/test answers an unknown name 200 {ok:false} where every sibling NAME route answers 404 (the #25486 family) #27510): the primary datasource is not looked up (it may have no stored record), and any other name with no saved record throws the package's onedatasourceNotFoundError(404,RESOURCE_NOT_FOUND,Datasource "NAME" does not exist.).404since datasources: GET /datasources/NAME/remote-tables and POST /datasources/NAME/object-draft answer an unknown name 400 EXTERNAL_DATASOURCE_ERROR where GET /datasources/NAME answers 404 (the #25486 / #27510 family) #27618 (answerThrown). It gains a comment naming the answer.assertFederationSource): that guard refuses managed datasources and the primary one with400, and the ruling keeps a datasource that exists and has nothing federated at its200empty report.external-validation-plugin.ts) also callsvalidateDatasource; for a datasource deleted after its timer was armed, a tick lands in its existing catch (onewarn, no events) instead of returning an empty report silently. No code change there.external-datasource-service.tsand its test; the dispatch order had named only the route file.Tests
packages/rest/src/external-datasource-unknown-name.test.ts: validate onno_such_dsanswers404 RESOURCE_NOT_FOUNDinGET /datasources/:name's words; validate on a saved managed datasource (warehouse) and ondefaultkeeps200 { ok: true, results: [] }. RealExternalDatasourceServiceover the realHonoHttpServer.packages/rest/src/external-datasource-validate-scope.test.ts: the cell that pinned the old empty200for an unknown name now pins the404, still with no introspection and novalidateAllcall.packages/services/service-datasource/src/__tests__/external-datasource-service.test.ts:validateDatasourceon an unknown name rejects withstatus 404/code RESOURCE_NOT_FOUND/datasourceNotFoundError's message, withlistObjectsnever called and nothing introspected; a saved datasource nothing is bound to still answers the empty report.Red on main, ablation, results
main(da94c11) with only the new pins: rest validate cell red,expected { status: 200, success: true, … } to deeply equal { status: 404, success: false, … }; the two200cells green.@objectstack/service-datasourcetosrc/(rest's vitest alias), so no rebuild was in the path.packages/rest: Test Files 352 passed (352), Tests 7023 passed / 350 skipped.packages/services/service-datasource: Test Files 63 passed (63), Tests 1029 passed.packages/runtimesrc/external-validation*: Test Files 4 passed, Tests 44 passed.tsc --noEmit: rest exit 0, service-datasource exit 0.Acceptance notes
Verification
Gates at bdbdaae
node scripts/pm/dispatch-gates.mjs --commands: 62 families derived. All run; 61 exit 0;pnpm check:dual-build-cjs-loadsexit 3 (PREREQUISITE NOT MET, needs every package's dist), NOT MEASURED locally, CI runs it.dispatch-gates --ran: 62 derived, 61 run, 1 NOT-MEASURED, 0 UNRUN.pnpm lint: exit 0.node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD: exit 0.Generated by Claude Code