You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation samples dereference the result of an access-controlled read without checking it for null.
This breaks the stack's most basic documented rule. An access-controlled operation returns null for a single record, or [] for many, when access is denied — deliberately, so that a denial is indistinguishable from a missing row and leaks nothing. The project's own guidance says to always check for null afterwards, precisely because the denial and the absence look the same.
A sample that ignores it does not merely fail to compile under strict — at runtime it raises a TypeError for exactly the user whose access was denied. So it works in development, where the author is usually privileged, and breaks for the restricted user it was supposed to protect.
Known instances, found while fixing the same defect in the RAG documentation:
docs/content/concepts/field-types.md:632
docs/content/reference/fields-api.md:1663 and :1718
and others across the documentation site
Two were already fixed and are not part of this issue: packages/rag/CLAUDE.md:540, and one in a pending changeset which was corrected because it publishes as a release note.
What to do
Sweep the documentation for reads through context.db whose result is dereferenced without a null check, and fix each. Both spellings matter: a single-record read returning null, and a first-or-null read.
Where a sample is deliberately showing the unchecked form to make a point, say so in its prose.
The check that would prevent recurrence
Nothing catches this: Markdown is not typechecked, and the docs link-check validates only internal links. Under strict these are TS18047 and TS18049 — a compiler catches them for free.
PR #1324 adds a checker that extracts every fenced TypeScript block and compiles it. It currently runs over a listed set of files. Extending that list to the whole documentation tree would catch this class permanently, and #1301 and #1317 along with it.
The problem
Documentation samples dereference the result of an access-controlled read without checking it for null.
This breaks the stack's most basic documented rule. An access-controlled operation returns
nullfor a single record, or[]for many, when access is denied — deliberately, so that a denial is indistinguishable from a missing row and leaks nothing. The project's own guidance says to always check for null afterwards, precisely because the denial and the absence look the same.A sample that ignores it does not merely fail to compile under
strict— at runtime it raises aTypeErrorfor exactly the user whose access was denied. So it works in development, where the author is usually privileged, and breaks for the restricted user it was supposed to protect.Known instances, found while fixing the same defect in the RAG documentation:
docs/content/concepts/field-types.md:632docs/content/reference/fields-api.md:1663and:1718Two were already fixed and are not part of this issue:
packages/rag/CLAUDE.md:540, and one in a pending changeset which was corrected because it publishes as a release note.What to do
Sweep the documentation for reads through
context.dbwhose result is dereferenced without a null check, and fix each. Both spellings matter: a single-record read returningnull, and a first-or-null read.Where a sample is deliberately showing the unchecked form to make a point, say so in its prose.
The check that would prevent recurrence
Nothing catches this: Markdown is not typechecked, and the docs link-check validates only internal links. Under
strictthese areTS18047andTS18049— a compiler catches them for free.PR #1324 adds a checker that extracts every fenced TypeScript block and compiles it. It currently runs over a listed set of files. Extending that list to the whole documentation tree would catch this class permanently, and #1301 and #1317 along with it.
Context
_Generated by Claude Code