Repository navigation
fix(api): reject BlockNote block types the web editor cannot render - #838
Conversation
A comment carrying a block type outside the editor's schema (an HTML tag name such as "p" instead of "paragraph") is stored and then crashes the whole task view on render — `t.nodes[e.type].isInGroup` on an undefined node type — and the server-side get_task path dies on the same record with `propSchema` of undefined. Nothing validated the type, and nested children were not inspected at all. Add internal/pkg/blocknote with the block types the editor can render (BlockNote 0.48 defaultBlockSpecs plus the custom mermaid and annotationCard blocks) and a validator that walks nested children. Route task descriptions and document content (dto.ValidateBlockNoteContent) and task/document comments (activity.IsCommentContentValid) through it, so the write fails with 400 / ACTIVITY_COMMENT_CONTENT_INVALID instead of storing content nobody can open. Refs Paca-AI#837
There was a problem hiding this comment.
ℹ️ No critical issues — one minor suggestion inline, plus an inline-content follow-up.
Approach: sound — one allow-list plus a recursive validator, wired into both places that persist BlockNote documents (dto.ValidateBlockNoteContent for task descriptions and document content, activity.IsCommentContentValid for task/doc comments), so every writer goes through the same check.
Reviewed changes
- New
internal/pkg/blocknote—Types(the 16 renderable block types) andValidate, which walks nestedchildrenand reports the index and type of the offending block. I diffed the list against the pinned@blocknote/[email protected]source andapps/web/src/components/shared/blocknote-schema.tsx; it matches exactly, andcustomSchemais the only editor schema the web uses. dto.ValidateBlockNoteContentnow delegates to it; absent/nullhandling and the array-shape error message are unchanged.activity.IsCommentContentValidvalidates the block-array path while leaving the legacy{"text": …}shape alone.- Tests cover unknown top-level and nested types, the missing-type case, and a
400 ACTIVITY_COMMENT_CONTENT_INVALIDover HTTP; theteamMentionContentfixture now setstype: "paragraph".
Verified locally: the blocknote, dto and activity packages and go test ./test/integration -run TestActivities_AddComment pass; go vet is clean.
ℹ️ Unknown inline content types still crash the same way
Validate inspects only a block's type and children, so a payload with a bogus inline type — [{"type":"paragraph","content":[{"type":"p","text":"hi"}]}] — is still stored and still takes the view down: BlockNote converts inline content on the same load path through blockOrInlineContentToContentNode, which throws node type p not found in schema. The issue defers this because a false rejection "would break mention writes", but a type-only allow-list (text, link, teamMention, taskReference, docReference) cannot reject a mention — only prop validation could. Worth a follow-up.
Technical details
# Unknown inline content types remain unvalidated
## Affected sites
- `services/api/internal/pkg/blocknote/blocknote.go:50` — `validateBlocks` reads `type` and `children` only; block `content` (inline nodes) and table cells (`content.rows[].cells[].content`) are never inspected.
- `apps/web/src/components/shared/blocknote-schema.tsx` — the editor inline schema is `defaultInlineContentSpecs` (`text`, `link`) plus `teamMention`, `taskReference`, `docReference`.
## Required outcome
- Inline content the editor cannot render is rejected on write (or normalised on read), so one bad inline node cannot crash the task or document view.deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| var arr []json.RawMessage | ||
| if json.Unmarshal([]byte(trimmed), &arr) == nil { | ||
| return true | ||
| return blocknote.Validate(content) == nil |
There was a problem hiding this comment.
| return blocknote.Validate(content) == nil | |
| if err := blocknote.Validate(content); err != nil { | |
| return false // TODO: propagate err so the 400 names the index/type | |
| } | |
| return true |
There was a problem hiding this comment.
Correction: ignore the suggested edit above (it only adds a TODO) — the actual finding is that IsCommentContentValid collapses blocknote.Validate's error to a bool, so a non-empty comment rejected for {"type":"p"} still returns the misleading message activity: comment content must not be empty and loses the index/type promised in the issue's acceptance criteria; propagating a wrapped error from AddComment/UpdateComment/AddSystemComment keeps errors.Is and the 400 code intact while naming the offending block.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Fixes #837.
What
The API accepted any block
typein BlockNote content, and never looked inside nestedchildren. A single comment carrying{"type":"p"}(an HTML tag name) therefore took a whole task view down in the web app:@blocknote/coreresolves every block type against the editor schema while rendering, so the miss is fatal for the view, not just for that one block. The same record also broke server-side rendering (get_task:Cannot read properties of undefined (reading 'propSchema')).Change
internal/pkg/blocknote: the block types the editor renders — BlockNote 0.48defaultBlockSpecsplus the app's custom blocks fromapps/web/src/components/shared/blocknote-schema.tsx(mermaid,annotationCard) — andValidate, which walks nestedchildrenand reports the offending index and type.dto.ValidateBlockNoteContent(task description create/update, document content create/update) now delegates to it. Array-shape errors keep their existing message.activity.IsCommentContentValid(task comments and document comments, add and update) applies the same check to the block-array path. The legacy{"text": "…"}shape and all existing error codes are unchanged.teamMentionContentininternal/service/task/activity_service_test.gobuilt a block with notypeat all — the same defect in test form; it now usesparagraph.Rejection surfaces as
400 ACTIVITY_COMMENT_CONTENT_INVALIDfor comments and the existing 400 for description/document writes, so an agent that wrote the bad payload can see what it did wrong.Tests
internal/pkg/blocknote: all renderable types (including nested children,mermaid,annotationCard,table) accepted; unknown top-level type, unknown nested type and missing type rejected.dto: unknown top-level and nested block types rejected, existing cases unchanged.activityservice:pblock and nestedpchild rejected with the kind's invalid-content error.POST .../activities/commentswith{"type":"p"}and with a nestedpchild →400+ACTIVITY_COMMENT_CONTENT_INVALID.Sabotage proof (each behaviour stubbed separately, restored after):
Gates, all inside
services/apion this commit:go build ./...,go vet ./...,golangci-lint run --timeout=5m(0 issues),go test -race $(go list ./... | grep -v '/test/e2e'),git diff --check. ThePACA_E2Esuite was not run (needs the cluster-backed harness).Not covered
teamMention,taskReference,docReference, …): the reported crash is block-type-only, and a false rejection there would break mention writes.type, keep the block ids).internal/pkg/blocknotecarries that note next to the list.