Skip to content

Feature/elelog 693 patch documents handler writes malformed ypath when#2620

Open
gularsson wants to merge 2 commits into
mainfrom
feature/elelog-693-patch-documents-handler-writes-malformed-ypath-when
Open

Feature/elelog 693 patch documents handler writes malformed ypath when#2620
gularsson wants to merge 2 commits into
mainfrom
feature/elelog-693-patch-documents-handler-writes-malformed-ypath-when

Conversation

@gularsson
Copy link
Copy Markdown
Contributor

No description provided.

gularsson added 2 commits May 19, 2026 18:10
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.
@gularsson gularsson self-assigned this May 19, 2026
Copy link
Copy Markdown
Contributor

@vilindh vilindh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a minor suggestion

)
return {
statusCode: 400,
statusMessage: 'Assignment not found'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to tack on the document id to the error message

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.

2 participants