Skip to content

Docs samples dereference access-controlled reads without a null check, so they break for exactly the denied user #1333

Description

@borisno2

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 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.

Context


_Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions