Repository navigation
fix(documents): keep AI document writes when citation parsing fails - #865
Draft
posthog[bot] wants to merge 2 commits into
Draft
posthog[bot] wants to merge 2 commits into
posthog[bot] wants to merge 2 commits into
Conversation
A linkedom crash during citation resolution failed the whole workspace_create_items call, so the user lost the document. The resolver now records the failure with the HTML length and SHA-256 and passes the HTML on unresolved. The sanitize step then keeps each citation as a plain label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: d4435402-b918-431e-a5ac-3879975d365d
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: d4435402-b918-431e-a5ac-3879975d365d
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
This branch has not been deployed
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.
Problem
TypeErrorin citation parsing escapesresolveDocumentCitationsand fails the fullworkspace_create_itemscall (alsoworkspace_edit_item).Origin
Changes
resolveDocumentCitationscatches a failure in the citation read or apply step and passes the original HTML on.parseDocumentAiHtmlalready turns each unresolved<citation>into its plain-text label, so the write continues with labels in place of links.recordOperationalFailureasdocument_citation_resolution, withhtml_length,html_sha256,operation_idandworkspace_id. The next occurrence gives an input fingerprint, not only a stack.create-items.test.ts: citation parsing throws → the document is created and the citation is plain text. The test fails without the fix.Warning
parseDocumentAiHtmlparses the same HTML with linkedom again. If the crash is deterministic for that input, the second parse can also throw. In that caseworkspace_create_itemsreturns a per-iteminvalid_initial_contentfailure in place of a failed tool call. The model sees the failure and can retry, and other items in the batch continue. This fix does not guarantee that the document is saved in that case.Testing
vp check: format, lint and typecheck pass.vp test --run --project=node: all pass exceptsrc/integrations/posthog/build.test.ts. That test also fails on unchangedmainin the sandbox, because of missingVITE_POSTHOG_*env.workerstest project andciBuild. They need the Cloudflare runtime and build env, which the sandbox does not have.Agent context
<template>and mis-nested markup parsed cleanly, which matches the report's fuzzing result.readDocumentCitationRefs/applyDocumentCitationLocations. One catch covers both calls and has the workspace context for telemetry. It also covers the ref-index lookup, because a citation is not worth the full write.Created with PostHog Desktop from this inbox report.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.