Conversation
Sequencer write path rejects spaces without settings.name and writes settings in the same INSERT, so NULL settings is unreachable. Verified on prod: 0 of 91,766 spaces have NULL settings. Schema tightened to NOT NULL to match. Closes #2220
There was a problem hiding this comment.
Pull request overview
This PR tightens the Hub’s spaces.settings column to be non-nullable (matching the current invariant enforced by the sequencer write path) and removes now-redundant settings IS NOT NULL SQL predicates from several GraphQL operations.
Changes:
- Update Hub schema (
schema.sql) to declarespaces.settings JSON NOT NULL. - Remove
spaces.settings IS NOT NULLguards from space/proposal lookups invotesandproposalresolvers. - Simplify
subscriptionsquery filtering by dropping thesettings IS NOT NULLpredicate (retaining the existing dynamicWHEREbuilding approach).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/hub/src/helpers/schema.sql | Makes spaces.settings non-nullable in the Hub schema definition. |
| apps/hub/src/graphql/operations/votes.ts | Removes redundant settings IS NOT NULL filtering from space/proposal fetches. |
| apps/hub/src/graphql/operations/subscriptions.ts | Drops the settings IS NOT NULL clause while keeping dynamic filtering via WHERE 1=1. |
| apps/hub/src/graphql/operations/proposal.ts | Removes redundant settings IS NOT NULL filtering from the proposal fetch query. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
chai3-bot
left a comment
There was a problem hiding this comment.
apps/sequencer/test/schema.sql still declares spaces.settings as nullable. The sequencer integration workflow initializes MySQL from that file (.github/workflows/sequencer-test.yml), so the write path that is being used to justify this invariant is still tested against the old schema and would not catch a future insert of NULL settings.
Please update that schema to settings JSON NOT NULL as well, so both schema definitions agree and the sequencer integration tests exercise the production constraint.
|
Tested this locally end to end (MySQL 8.0, applied this PR's What I checked
Minor
One deployment note to be explicit about: the guard-drop and the |
chai3-bot
left a comment
There was a problem hiding this comment.
Re-reviewed at ab5057273796cdbaf781bdca29d09cda92655de8, including the failed CI check. No code findings.
The lint-build-test job passed install, build, typecheck, lint, and unused-code checks, then failed only because the unrelated UI test apps/ui/src/helpers/utils.test.ts:320 timed out after 10 seconds while resolving boorger.shib. This PR changes only Hub query/schema files and the Sequencer test schema; the dedicated Hub and Sequencer test workflows both pass. This appears to be a flaky external name-resolution timeout, not a regression from this PR. A maintainer will need to rerun it because this bot lacks rerun permission.
tony8713
left a comment
There was a problem hiding this comment.
Approving. Verified locally end-to-end (see my earlier comment): the guards were genuinely dead, all three resolvers pass on the NOT NULL schema, the constraint is enforced, and behavior is unchanged for every real row. The CI red was a flaky unrelated apps/ui test (live mainnet RPC lookup for boorger.shib timing out) — reran and it's green now.
ChaituVR
left a comment
There was a problem hiding this comment.
utAck, not sure about schema change on prod
| id VARCHAR(64) NOT NULL, | ||
| name VARCHAR(64) NOT NULL, | ||
| settings JSON, | ||
| settings JSON NOT NULL, |
There was a problem hiding this comment.
No, this will need a schema update on the prod database
There was a problem hiding this comment.
Deploy request: https://app.planetscale.com/snapshot/snapshot-hub/deploy-requests/22
@bonustrack confirm, then we can merge
Already changed on testnet
Drops the four vestigial
spaces.settings IS NOT NULLpredicates and tightensspaces.settingstoNOT NULLin the schema. The NULL state is unreachable: the sequencer write path rejects spaces withoutsettings.nameand writes settings in the same INSERT. Verified on prod: 0 of 91,766 spaces have NULL settings.Closes #2220
Deployment note
Prod requires a manual
ALTER TABLE spaces MODIFY settings JSON NOT NULL;— safe to run before or after deploy since no NULL rows exist.Test plan