Repository navigation
fix(db-sync): the semantic API answers 400 to a write the graph does not allow - #13772
Closed
yuxi-liu-wired wants to merge 5 commits into
Closed
yuxi-liu-wired wants to merge 5 commits into
yuxi-liu-wired wants to merge 5 commits into
Conversation
…thout a string title
…t is not a string
… only an entity id
yuxi-liu-wired
force-pushed
the
fix/semantic-validation-400
branch
from
October 16, 2026 18:36
405eb25 to
12e791d
Compare
Contributor
Author
|
Combined with the other PRs that change the same files into #13781. |
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.
The semantic API answers a write the graph does not allow with 500 "server error" and a debug stack. Examples:
POST /semantic/pageswith titlea/b("Page name can't include "/""),POST /semantic/tagswith#tag,PATCHorDELETEof a built-in page or block ("Built-in nodes can't be modified", "Built-in nodes can't be deleted").The outliner rejects such writes by throwing an error meant to notify the user (
ex-data:type :notification, the message in:payload). The semantic handlers check some inputs themselves and answer 400, but these errors come from inside the outliner call and reachhandle-http's catch-all, which answers 500.semantic/handlenow answers 400 with the error's message for an error of:type :notification, synchronous or from a promise. Every other error still reaches the 500 path.The routes that insert a block tree (
/semantic/capture,/semantic/blocks/:block-id/children,/semantic/block-trees) checked thatblocksis a non-empty list but not its blocks: a block whose title is not a string ({"blocks": [{"title": 1}]}, or a child{}) failed an assert,(string? title), answered 500. They now check the whole tree (every block a map with a stringtitleand optionalchildrenof the same shape) and answer 400 as for a missing list.The property routes resolved
:property-idto the ident of any entity it names:PUT /semantic/blocks/:block-id/properties/logseq.class%2FTask(a class, not a property) set it as a property and failed with "No validation for property type nil", answered 500.resolve-property-identnow returns an ident only for a property, so such a request answers 400 "property not found" as for a missing one.PATCH /semantic/properties/:property-idtook anytitle:{"title": {}}failed with "str.indexOf is not a function", answered 500. Atitlethere must now be a non-blank string, as on the other write routes.A value for a ref property (status, priority, tags, node) that is a number went to
d/entityas an entity id. Datascript throws on a number that is not one (-1,1.5: "Expected number or lookup ref for entity id"), answered 500, onPUT /semantic/blocks/:block-id/properties/:property-idandPOST /semantic/block-properties/batch-set. Only a positive integer is now looked up; another number resolves to nothing and answers 400 as for a missing entity.Test:
semantic-write-the-graph-does-not-allow-answers-400-test(a page titleda/b, a tag titled#tag, a capture of a block titled1, a capture of a child without a title, a class named as the property, a property update with an object as title, a status value of-1and of1.5).Found by a fuzzer that sends random semantic API requests to a server on a full graph.