fix: reject legacy v4 'schema' field in DDL ops with 400 error#455
Draft
fix: reject legacy v4 'schema' field in DDL ops with 400 error#455
Conversation
In v5, 'database' replaced 'schema' as the field name for database identification in DDL operations. Callers using the v4 'schema' field received a 200 success response but the operation silently failed cluster-wide — a foot-gun with no diagnostic signal. Adds rejectLegacySchemaField() called after Joi validation and before transformReq() in all DDL functions (dropTable, dropSchema, createTable, createSchemaStructure, dropAttribute, createAttribute). Internal replicated calls are unaffected because transformReq() on the originating node sets both fields before forwarding to peer nodes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Reviewed; no blockers found. |
cb1kenobi
approved these changes
May 2, 2026
cb1kenobi
approved these changes
May 4, 2026
Member
cb1kenobi
left a comment
There was a problem hiding this comment.
Is this considered a breaking change?
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.
Summary
rejectLegacySchemaField()helper indataLayer/schema.jsthat throws a400 ClientErrorwhenschemais provided withoutdatabasedropTable,dropSchema,createSchemaStructure,createTable,dropAttribute,createAttributePurpose
In v5 the
databasefield replaced v4'sschemafield for identifying the database in DDL operations. A caller using the legacyschemafield received a 200 success response but the operation failed silently cluster-wide —Promise.allSettledinreplicateOperationabsorbs remote failures and the success message is always written over the response. There was no signal that anything went wrong.Design decision worth reviewing
Check placement: After Joi validation, before
transformReq(). This is intentional —transformReqsetsreq.schema = req.databaseon the originating node before replication, so replicated calls always have both fields set;rejectLegacySchemaFieldonly fires whenschemais present withoutdatabase, which uniquely identifies the legacy external API case.Skipped existing tests: The
describe.skip('Test schema module')block contains test constants (DROP_TABLE_OBJECT_TEST, etc.) that useschemawithoutdatabase. These would fail if unskipped, but updating them is a separate cleanup. They were already skipped before this change.Attention
dropSchemaJoi schema uses.or('database', 'schema')for backwards compat;rejectLegacySchemaFieldthen provides the more specific error. No change to the Joi schema was needed.transformReqwithschema/databasebut are out of scope — this was a DDL-specific report.🤖 Generated with Claude Code