[WIKI-704] fix: hocuspocus error handling#7898
Conversation
WalkthroughAdds xmlns to allowed HTML attributes in the API sanitizer. In the live app, centralizes error normalization in database extension and adjusts page service to rethrow full errors instead of response data. Also ensures an awaited update call in document storage. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Ext as extensions/database.ts
participant Service as page/core.service.ts
participant API as Backend API
rect rgba(220,235,255,0.5)
note over User,Ext: Fetch document flow
User->>Ext: fetchDocument(pageId)
Ext->>Service: fetchDescriptionBinary(pageId)
Service->>API: GET /pages/:id/description
API-->>Service: 200/4xx/5xx
alt success
Service-->>Ext: data
Ext-->>User: document
else error
Service-->>Ext: throw Error (full error)
Ext->>Ext: normalizeToError(e, "Failed to fetch document: :id")
Ext-->>User: throw Error
end
end
rect rgba(220,255,220,0.5)
note over User,Ext: Store document flow
User->>Ext: storeDocument(pageId, payload)
Ext->>Service: updateDescriptionBinary(pageId, payload) (await)
Service->>API: PUT /pages/:id/description
API-->>Service: 200/4xx/5xx
alt success
Service-->>Ext: result
Ext-->>User: ok
else error
Service-->>Ext: throw Error (full error)
Ext->>Ext: normalizeToError(e, "Failed to update document: :id")
Ext-->>User: throw Error
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/api/plane/utils/content_validator.py(1 hunks)apps/live/src/extensions/database.ts(3 hunks)apps/live/src/services/page/core.service.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
apps/api/plane/utils/content_validator.py (1)
87-87: LGTM! xmlns addition aligns with tiptap v3 requirements.Adding xmlns to the wildcard attributes is appropriate for supporting tiptap v3's HTML output. The attribute is safe within the nh3 sanitization context and does not introduce security risks.
apps/live/src/services/page/core.service.ts (2)
23-25: LGTM! Full error propagation preserves context.Rethrowing the complete error object instead of just
error?.response?.dataensures stack traces and error metadata are preserved, improving debuggability.
37-39: LGTM! Consistent with fetchDetails error handling.This change mirrors the error handling improvement in
fetchDetails, ensuring both methods propagate full error context consistently.apps/live/src/extensions/database.ts (3)
14-22: LGTM! Robust error normalization utility.The
normalizeToErrorhelper ensures consistent Error objects across error paths, improving type safety and debuggability by preserving existing Error instances while converting other types to Error with meaningful messages.
40-43: LGTM! Enhanced error context for fetch failures.Using
normalizeToErrorwith a descriptive fallback message improves error reporting when fetching documents fails, making it easier to diagnose issues in production.
59-62: LGTM! Consistent error handling in store operation.The error normalization with context message aligns with the
fetchDocumentpattern, providing consistent error reporting across both database operations.
|
Linked to Plane Work Item(s) This comment was auto-generated by Plane |
Description
Fixes a bug with html validation with tiptap v3 while saving html
Type of Change
Summary by CodeRabbit