Skip to content

fix(schema): log warning when removing non-existent field#23

Open
lotaar wants to merge 1 commit into
redis-developer:mainfrom
lotaar:fix/schema-remove-field-warning
Open

fix(schema): log warning when removing non-existent field#23
lotaar wants to merge 1 commit into
redis-developer:mainfrom
lotaar:fix/schema-remove-field-warning

Conversation

@lotaar
Copy link
Copy Markdown

@lotaar lotaar commented May 12, 2026

📝 Summary

Adds a warning when IndexSchema.removeField() is called with a field name that does not exist in the schema. The warning includes the requested field name and a list of currently available fields to help diagnose typos or incorrect API usage.

🎯 Motivation

Previously, removeField() silently no-opped when the target field was missing. This made it difficult to catch configuration errors or typos during development, as invalid removal attempts went completely unnoticed.

🛠 Changes

  • src/schema/schema.ts: Updated removeField() to emit a console.warn() when the field is not found, matching the existing warning pattern used in src/query/vector.ts.
  • tests/unit/schema/schema.test.ts: Added 3 unit tests:
    • ✅ Warning includes field name and available fields when schema is populated
    • ✅ Warning shows (none) when schema is empty
    • ✅ No warning is emitted when an existing field is successfully removed (regression guard)

🧪 Testing

  • npm run test:unit passes
  • npm run type-check & npm run type-check:tests pass
  • npm run lint & npm run format:check pass
  • Tests follow the project's TDD workflow and use vi.spyOn(console, 'warn') consistent with existing test patterns.

✅ Acceptance Criteria

  • Warns when the field isn't present in the schema
  • Includes the field name and list of known field names in the warning
  • Unit tests added

🔗 Closes #13

@lotaar lotaar changed the title [object Object] fix(schema): log warning when removing non-existent field May 12, 2026
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.

Log a warning when removing a non-existent field

1 participant