Feature/elelog 693 patch documents handler writes malformed ypath when#2620
Open
gularsson wants to merge 2 commits into
Open
Feature/elelog 693 patch documents handler writes malformed ypath when#2620gularsson wants to merge 2 commits into
gularsson wants to merge 2 commits into
Conversation
The PATCH /api/documents/:id handler destructured the result of
getAssignment() with `|| {}`, so when no matching assignment existed
on the document the resulting `index` was undefined and the code
proceeded to call setValueByYPath with a path like
`meta.core/assignment[undefined].data.publish`, which either threw
or wrote garbage into the YDoc without surfacing a meaningful error.
Detect the missing assignment, skip the mutation, and return a 400
once the transaction has completed. Add server-side tests covering
both the not-found and the happy path for status=withheld.
- Return a short stable "Assignment not found" 400 message and log the document/deliverable details via the logger instead of echoing them to the client. - Export RouteContext from routes.ts and use it in the new test, replacing the inline MockRouteContext interface and the `as unknown as ... as never` cast with a single `as unknown as RouteContext`. - Broaden the regression assertion to check that no meta key contains the literal "[undefined]" segment, instead of only the single "core/assignment[undefined]" key.
vilindh
approved these changes
May 21, 2026
Contributor
vilindh
left a comment
There was a problem hiding this comment.
Looks good, just a minor suggestion
| ) | ||
| return { | ||
| statusCode: 400, | ||
| statusMessage: 'Assignment not found' |
Contributor
There was a problem hiding this comment.
Might be a good idea to tack on the document id to the error message
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.
No description provided.