Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c5bd0a369d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const validationError = validateMemoryInput({ | ||
| type: normalized.type, | ||
| content: normalized.content, | ||
| source_agent: normalized.source_agent, | ||
| importance: normalized.importance, |
There was a problem hiding this comment.
Preserve metadata validation in normalization helper
This new centralized validation path does not pass metadata into validateMemoryInput, so POST /memory no longer enforces the metadata type/size/depth checks that were previously applied to req.body. In practice, malformed or deeply nested metadata now reaches scrubObject(metadata) and can trigger avoidable runtime failures or heavy recursive work instead of returning a deterministic 400 validation error.
Useful? React with 👍 / 👎.
| if (typeof authHeader === 'string' && authHeader.startsWith('Bearer ')) { | ||
| const bearerToken = authHeader.slice('Bearer '.length).trim(); | ||
| if (bearerToken) return { key: bearerToken, source: 'bearer' }; |
There was a problem hiding this comment.
Parse Bearer auth scheme case-insensitively
Bearer scheme matching is currently case-sensitive (startsWith('Bearer ')), but HTTP auth schemes are case-insensitive, so valid headers like authorization: bearer <token> are rejected with 401. Since this commit introduces Bearer-token support, this causes legitimate clients/proxies using lowercase schemes to fail authentication unexpectedly.
Useful? React with 👍 / 👎.
Motivation
Description
ALLOW_QUERY_API_KEYenv flag and document it inREADME.mdand.env.example, and wire it into authentication behavior.api/src/middleware/auth.js) to use a newextractKeyflow that acceptsx-api-key,Authorization: Bearer ..., and optionally?key=..., setsreq.authSourceandreq.rateLimitKey, and returns a clear 401 when query keys are disabled.api/src/middleware/ratelimit.js) to preferreq.rateLimitKeyfor bucketing so rate limits apply to the resolved authenticated identity.api/src/services/memory-write-utils.jsprovidingnormalizeMemoryRecord,normalizeImportRecord, andbuildDedupExtraFilter, and updatememoryandexportroutes to use these utilities for normalization, content hashing, deduplication (scoped byclient_idandtype), embedding, and structured-store writes.client_idfiltering tolistStatusesimplementations in both Postgres and SQLite stores and remove duplicated SQLite schema block.api/tests/auth.test.js,api/tests/ratelimit.test.js, andapi/tests/memory-write-utils.test.js.Testing
api/tests/auth.test.js,api/tests/ratelimit.test.js, andapi/tests/memory-write-utils.test.js, and all tests passed.authMiddlewareacceptsx-api-key,Bearertokens, and conditionally accepts query keys whenALLOW_QUERY_API_KEY=truevia unit tests.rateLimitMiddlewarebuckets requests byreq.rateLimitKeyand enforces limits per resolved identity via unit tests.Codex Task