Repository navigation
fix(blog): make the extend-existing-systems datasource sample parse - #308
Merged
Merged
Conversation
The connect-route sample nested its keys under `config.connection`, spelled `user` for `username`, and inlined a password. On @objectstack/spec 18.2.0 (npm `latest`) the Postgres driver's strict config schema refuses all three. Rewrite it as `defineDatasource` with a flat `config` (host, database, username from the environment) and the password bound through the secret store via `external.credentialsRef`, in all seven authored locales; zh-Hant regenerated. Set `updated` to 2026-10-29; `date` unchanged. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvdwLLfobyXipfCGq7
This was referenced Oct 29, 2026
Contributor
Author
|
repo:www#3 · os-tesla · session_01L9qibvdwLLfobyXipfCGq7 席位核对ACCEPT on head
Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Tesla · project thread
Fixes #175
Clause-②: no
Metadata-protocol: none
维护者速读
updated改为 2026-10-29。@objectstack/spec18.2.0)上直接被拒,还把密码写进了配置,正好违背文中"凭据不写进源码"那句话;读者和 AI 复制的第一段代码就是它。updated行会冲突),后落地者解决。content/blog/extend-existing-systems-with-ai/index.mdx第 1 步代码块及其前后两段;index.zh-Hans.mdx同处。/en/blog/extend-existing-systems-with-ai/,第 1 步代码应为defineDatasource(...)、config平铺host/database/username、无password,页头显示 "Updated Oct 29, 2026"。What changes
The step-1 datasource sample in
extend-existing-systems-with-ai, in all eight locale files (seven authored,zh-Hantregenerated bypnpm gen:zh-hant):import type { Datasource } from '@objectstack/spec'+ annotated literal becomesdefineDatasourcefrom@objectstack/spec/data.config.connection.{host,user,password,database}becomes a flatconfigwithhost,database,usernamefrom the environment, and no password.external: { credentialsRef: process.env.BIZ_DB_CREDENTIALS_REF }. On a managed datasourcecredentialsRefis the oneexternalkey allowed (spec #8153).external.credentialsRef) on the datasource. The read-replica / read-only DB user advice stays as it was.defineDatasourcechecks the declaration against the Postgres driver's config schema when the file loads.updated: 2026-10-29T10:00:00+08:00in every locale.dateis unchanged.The code block is byte-identical in all eight files. The block has no comments, so nothing needed translating.
Why
defineDatasourceand notDatasource. In the published 18.2.0 spec,defineDatasource's own doc comment calls it "preferred over a bare: Datasourceliteral". It also runsDatasourceSchema.parse(). TheDatasourcetype typesconfigasz.record(string, unknown), so the old literal type-checks and only fails at parse. The ObjectStack guidecontent/docs/data-modeling/external-datasources.mdxusesdefineDatasourceimported from@objectstack/spec/data. The post's other samples also import from/data. Both the root and/dataexport it in 18.2.0.Tests
Measured against
@objectstack/spec@18.2.0.npm view @objectstack/cli dist-tagsreturns{ latest: '18.2.0', next: '18.2.0' }, and@objectstack/specis the same. The source read was objectstackorigin/main@4a00b2b7.Old sample: refused
Flattened, the same keys still fail twice:
New sample: parses (code block extracted from `index.mdx`, run under node)
Control: adding
password: 'x'to the newconfigis refused (["config","password"] ... not accepted inline). With the env vars unset, the parse refuses loudly on["config","database"]("needs a connection target") instead of silently using defaults.tsc --strict(TypeScript 5.9.3,moduleResolution: nodenext) on the sample against the 18.2.0 types: exit 0.Acceptance notes
schemaMode: 'external'. The closing section corrected underextend-existing-systems-with-aitells readers ADR-0015 federation is *Proposed* and unshipped — it is Accepted and shipped #149 keeps federation gates separate from DB-level read-only, and this PR leaves that as it is.updated). Expect a one-lineupdated:conflict for whichever lands second.passwordguidance on the datasource top level still says "Interpolate it from the environment insideconfig", which every driver contract now refuses. Theexternal.passwordguidance givessecret:warehouse/passwordas an example, and the guide says that form does not dereference. Thedrivers.mdxread-only section says the parse rejectsexternalon a managed datasource, but 18.2.0 acceptsexternal.credentialsRefthere.Verification
Head
12a9f3a, worktree offmain@6d95393:pnpm install --frozen-lockfilepnpm content:lintcontent lint passed (383 files, 46 glossary terms checked), no warning on this post)pnpm check(under the shared verify lock)0 errors, 0 warnings, 0 hints, 160 files)pnpm build(under the shared verify lock)content lint --distlinks/CJK/quotes passed)pnpm seo:smokeSEO smoke test passed (938 HTML pages checked ...))Browser check of the built
dist/(Playwright Chromium) foren,zh-Hansandjaat 1440×750 and 390×844, with the screenshots looked at. The code block and the new sentences render, and the header reads "Updated Oct 29, 2026".dateModifiedandarticle:modified_time=2026-10-29T02:00:00.000Z. There is no horizontal page overflow. At 390px the code block scrolls horizontally behind the site's fade, the same as the old block and this post's second sample.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibvdwLLfobyXipfCGq7