Skip to content

feat: return 422 for malformed OpenSearch query syntax#15

Merged
johnf merged 1 commit intomainfrom
feat/search-malformed-query-422
Mar 30, 2026
Merged

feat: return 422 for malformed OpenSearch query syntax#15
johnf merged 1 commit intomainfrom
feat/search-malformed-query-422

Conversation

@johnf
Copy link
Copy Markdown
Collaborator

@johnf johnf commented Mar 27, 2026

Summary

  • Detect OpenSearch 400 errors (e.g. parsing_exception from invalid query_string syntax) and return 422 with INVALID_REQUEST error code instead of a generic 500
  • Add createInvalidRequestError utility function
  • Includes test for the new behaviour

Depends on: #13

Test plan

  • pnpm lint passes
  • pnpm test passes
  • Malformed advanced search queries return 422 instead of 500

@johnf johnf force-pushed the refactor/error-handling branch from 4df54ab to 253aa48 Compare March 27, 2026 05:13
@johnf johnf force-pushed the feat/search-malformed-query-422 branch from 4d99510 to dec87d9 Compare March 27, 2026 05:13
Base automatically changed from refactor/error-handling to main March 30, 2026 23:17
Detect OpenSearch 400 errors (e.g. parsing_exception from invalid
query_string syntax) and return a 422 with INVALID_REQUEST error code
instead of a generic 500.
@johnf johnf force-pushed the feat/search-malformed-query-422 branch from dec87d9 to 5fcb9bd Compare March 30, 2026 23:18
@johnf johnf merged commit 38280cb into main Mar 30, 2026
1 check passed
@johnf johnf deleted the feat/search-malformed-query-422 branch March 30, 2026 23:19
@github-actions
Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 100% (🎯 100%) 328 / 328
🔵 Statements 100% (🎯 100%) 339 / 339
🔵 Functions 100% (🎯 100%) 52 / 52
🔵 Branches 100% (🎯 100%) 159 / 159
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/routes/search.ts 100% 100% 100% 100%
src/utils/errors.ts 100% 100% 100% 100%
Generated in workflow #62 for commit 5fcb9bd by the Vitest Coverage Report Action

github-actions bot pushed a commit that referenced this pull request Mar 31, 2026
## [3.0.0](v2.1.0...v3.0.0) (2026-03-31)

### ⚠ BREAKING CHANGES

* Entity and File primary keys change from auto-increment
integers to string-based IDs. Entity.rocrateId is renamed to Entity.id,
File.fileId is renamed to File.id. File now has an entityId foreign key
to Entity instead of Entity having a fileId. Redundant fields removed
from File (memberOf, rootCollection, contentLicenseId).

Also includes:
- findFirst replaced with findUnique for primary key lookups
- Promise.all for parallel count+findMany queries
- Simplified transformer types (removed discriminated unions)
* Existing databases must run the migration to rename
tables from Entity/File to entity/file.
* update to prisma 7.x

### Features

* make geohashPrecision optional in search aggregations ([#14](#14)) ([9e4a546](9e4a546))
* return 422 for malformed OpenSearch query syntax ([#15](#15)) ([38280cb](38280cb))
* update to prisma 7.x ([117efa0](117efa0))
* use string primary keys and normalise Entity/File schema ([#19](#19)) ([a864503](a864503))

### Bug Fixes

* rename database tables to lowercase ([#18](#18)) ([921fe65](921fe65))
* typescript error ([d078263](d078263))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants