fix(github): offer every database type and link the docs on first contact - #1308
fix(github): offer every database type and link the docs on first contact#1308aparajon wants to merge 2 commits into
Conversation
…tact The comment a user reaches before they have a working schemabot.yaml told them `type` must be `vitess` or `mysql`. Config validation accepts four types, so a Postgres or Strata adopter with a correct file was being told to break it. Both surfaces now read one registry, `storage.DatabaseTypes`, so the set SchemaBot accepts and the set it offers cannot drift apart. These comments also carried no way out: no link, and setup instructions that assumed a schema directory the reader does not have yet. Each now names the directory the file belongs in and links the page documenting it (UX-4). The link set is checked against the docs tree, so a page that moves or a heading that is reworded fails a test instead of shipping a 404. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
storage.DatabaseTypes is exposed as a mutable exported slice, creating an API footgun where external packages can silently alter validation and rendered UX at runtime.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves the “first-contact” GitHub PR comments shown when a repo’s schemabot.yaml is missing/invalid by (1) listing every supported database type (mysql/vitess/strata/postgres) from a single registry shared with config validation, and (2) adding stable documentation links (with tests that fail if links/anchors rot).
Changes:
- Introduce
storage.DatabaseTypes/storage.IsDatabaseTypeand use them for server-side config validation and template rendering so accepted vs offered types cannot drift. - Add
pkg/uidocumentation link constants (SchemaConfigDocURL,ThrottleDocURL) plus a test that validates pages exist and anchors resolve. - Update error templates +
TEMPLATES.mdexamples to include the docs link and clearer setup wording.
File summaries
| File | Description |
|---|---|
| TEMPLATES.md | Updates rendered template examples to include full type list and a link to setup docs. |
| pkg/webhook/templates/errors.go | Renders database type choices from storage.DatabaseTypes and adds a docs link to first-contact error comments. |
| pkg/webhook/templates/errors_test.go | Adds coverage ensuring first-contact comments include the docs link and all supported types. |
| pkg/ui/throttle.go | Moves ThrottleDocURL out of this file (now centralized in pkg/ui/docs.go). |
| pkg/ui/docs.go | Centralizes user-facing documentation URLs and enumerates them in DocLinks. |
| pkg/ui/docs_test.go | Validates DocLinks targets exist and (when present) anchors match real headings. |
| pkg/storage/types.go | Adds a shared database-type registry (DatabaseTypes) and validator (IsDatabaseType). |
| pkg/api/config.go | Switches database type validation to storage.IsDatabaseType and formats errors from storage.DatabaseTypes. |
Review details
- Files reviewed: 8/8 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The set of types a schemabot.yaml may declare is what config validation accepts, and its other readers only render it. Exporting the backing slice let any of those readers widen what validates by holding on to it, so the slice is unexported behind a DatabaseTypes() accessor that clones, matching RetiredControlOperations() beside it. Also rewords the DocsBaseURL doc comment, which read as a stutter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The comment a user reaches before they have a working
schemabot.yamltold themtypemust bevitessormysql. Config validation accepts four types, so an adopter arriving with a correct Postgres or Strata config was being told to break it — on the first comment SchemaBot ever posts them.Both surfaces now read one registry,
storage.DatabaseTypes, so the set SchemaBot accepts and the set it offers cannot drift apart:These comments also carried no way out: no link, and setup instructions that named "your schema directory" — a directory the reader does not have yet, since not having it is why they are reading the comment. Each of the four now names the directory the file belongs in and links the page documenting it (UX-4).
Documentation links move to
pkg/ui, and a test walks the link set against thedocs/tree and resolves each#anchoragainst a real heading, so a page that moves or a heading that is reworded fails CI instead of shipping a 404.Invariants: upholds UX-4 — the comment names the next action instead of reporting a condition. No other entry is touched.
No config found
ℹ️ No SchemaBot Configuration Found
Environment:
stagingRequested by @Someone at 2026-01-15 14:30:00 UTC
No
schemabot.yamlconfiguration file was found in this repository.Setup Instructions
Create a
schemabot.yamlfile in the directory holding the.sqlfiles that declare your tables:typeis one ofmysql,vitess,strata,postgres.Setting up
schemabot.yamlIf you already have a config
Use the
-dflag to specify which database to plan:Config present but incomplete
Environment:
stagingRequested by @Someone at 2026-01-15 14:30:00 UTC
The
schemabot.yamlfile must includedatabaseandtypefields:mysql,vitess,strata,postgresSetting up
schemabot.yamlDatabase not found
Database:
nonexistent-db| Environment:stagingRequested by @Someone at 2026-01-15 14:30:00 UTC
No
schemabot.yamlconfiguration withdatabase: nonexistent-dbwas found in this repository.Check that your
schemabot.yamlfile has the correctdatabasefield matching the-dflag value.Setting up
schemabot.yamlThis pull request was written by Claude Code (Claude Opus 5).