Repository navigation
fix(api): answer a missing memory with MEMORY_NOT_FOUND - #311
Merged
nathanschmid08 merged 1 commit intoNov 11, 2026
Merged
nathanschmid08 merged 1 commit into
nathanschmid08 merged 1 commit into
Conversation
Every resource in the API answers a missing row with its own code. The two
memory services did not: they threw the bare-string form of
NotFoundException, so the envelope fell back to the generic NOT_FOUND, the
same code the router emits for a route that does not exist. A client could
not tell "this memory does not exist" from "this endpoint does not exist"
except by reading prose in the message, the one field a client is not
supposed to branch on.
All seven throw sites now use the object form, like the sibling resources
and like the agent check one function up in the same service:
throw new NotFoundException({
code: 'MEMORY_NOT_FOUND',
message: `Memory with ID "${memoryId}" not found`,
});
The agent in the path keeps its own code (AGENT_NOT_FOUND): the agent in the
path and the memory under it are different misses, and keeping them apart
is the point.
The six service methods that can answer a missing memory now document the
code they raise, and the specs assert the code and not only the status,
which is what let this slip through.
Signed-off-by: Shounak Joshi <shounakjoshi88@gmail.com>
6 tasks done
Contributor
|
@all-contributors please add @shounakjoshi88-a11y for code |
Contributor
|
I've put up a pull request to add @shounakjoshi88-a11y! 🎉 |
Contributor
|
Hi @shounakjoshi88-a11y , Thanks for the PR. It is very much appreciated. |
Contributor
Author
|
Thank you for the review and the merge, and for the all-contributors entry - much appreciated. |
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.
What changed
A missing memory now answers with its own code,
MEMORY_NOT_FOUND, instead of the genericNOT_FOUNDthat the router also emits for a route that does not exist.Every resource in the API answers a missing row with its own
code. The two memory services did not: they threw the bare-string form ofNotFoundException, so the envelope fell back to the genericNOT_FOUND:The only thing separating "this memory does not exist" from "this endpoint does not exist" was prose in
message, the one field a client is not supposed to branch on.All seven throw sites now use the object form, like the sibling resources and like the agent check one function up in the same service:
memory/shared-memories/shared-memories.service.ts:findOne,update,removememory/agent-memories/agent-memories.service.ts:findOne,update,removeThe agent in the path keeps its own code (
AGENT_NOT_FOUND): the agent in the path and the memory under it are different misses, and keeping them apart is the point.The six service methods that can answer a missing memory now document the code they raise, and the specs assert the code and not only the status, which is what let this slip through.
Why
Closes #308
How it was tested
The eight new assertions fail without the change:
The lint, the format check and the build are clean for the four changed files.
npm run format:checkalso reports three files I did not touch (agent-memory.mapper.ts,shared-memory.mapper.ts,tag-helpers.spec.ts), which are already unformatted onmain.Anything left out, or worth a second opinion
docs/api-conventions.mddoes not list the codes, so it needs no change; it says acodeis stable and machine-readable and that an exception may supply a more specific one, which is what this does.@ApiNotFoundResponseon the memory routes, so there is no description to name the code in. The one that exists (agent-memories.controller.ts, onremoveAll) is about the agent and keepsAGENT_NOT_FOUND.MEMORY_NOT_FOUNDnow, as the issue asks; no separate code was invented for it.