Skip to content

fix: reject legacy v4 'schema' field in DDL ops with 400 error#455

Draft
kriszyp wants to merge 1 commit intomainfrom
fix/reject-legacy-schema-field
Draft

fix: reject legacy v4 'schema' field in DDL ops with 400 error#455
kriszyp wants to merge 1 commit intomainfrom
fix/reject-legacy-schema-field

Conversation

@kriszyp
Copy link
Copy Markdown
Member

@kriszyp kriszyp commented May 2, 2026

Summary

  • Adds rejectLegacySchemaField() helper in dataLayer/schema.js that throws a 400 ClientError when schema is provided without database
  • Applied to all DDL entry points: dropTable, dropSchema, createSchemaStructure, createTable, dropAttribute, createAttribute
  • 7 new unit tests covering rejection behavior and replication safety

Purpose

In v5 the database field replaced v4's schema field for identifying the database in DDL operations. A caller using the legacy schema field received a 200 success response but the operation failed silently cluster-wide — Promise.allSettled in replicateOperation absorbs 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 — transformReq sets req.schema = req.database on the originating node before replication, so replicated calls always have both fields set; rejectLegacySchemaField only fires when schema is present without database, 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 use schema without database. These would fail if unskipped, but updating them is a separate cleanup. They were already skipped before this change.

Attention

  • The dropSchema Joi schema uses .or('database', 'schema') for backwards compat; rejectLegacySchemaField then provides the more specific error. No change to the Joi schema was needed.
  • Other operations (search, insert, delete) also call transformReq with schema/database but are out of scope — this was a DDL-specific report.

🤖 Generated with Claude Code

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>
@kriszyp kriszyp requested a review from a team as a code owner May 2, 2026 00:27
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 2, 2026

Reviewed; no blockers found.

Copy link
Copy Markdown
Member

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this considered a breaking change?

@kriszyp kriszyp marked this pull request as draft May 5, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants