Testing
Troubleshooting & auditing
Find out why a query returned nothing, which access rule refused a write and why a read looked stale.
- In the schema
- —
Empty results instead of 403#
In Napalm, select access policies compile into SQL filter predicates instead of HTTP middleware exceptions. When a query returns { "data": [] } unexpectedly, walk through the four checks below in order.
SQL predicate filtering vs write refusals
Read and target-selection policies omit unauthorized rows as [] inside PostgreSQL, whereas insert and update write violations abort the transaction with 400 query_failed.
| Cause | Symptom | Fix |
|---|---|---|
| Closed default-deny type | Every caller, including backend service keys, receives [] on a newly created type. | FixUnlike upstream Gel, any stored type in Napalm without an access policy (declared or inherited) is completely closed (deny all) over the Project API from day one. Add an explicit allow policy on the new type. |
Service key has empty global caller | Queries work for signed-in users but return [] with an ndb_… service key. | FixA service key represents your backend instead of an ext::auth::Identity, so global ext::auth::ClientTokenIdentity is {}. Configure serviceGlobals (such as global is_service := true) and add a policy for that global, or act as the caller inside an action via call.db(). |
= instead of ?= on optional values | Policy unexpectedly fails or not (.flag = true) hides rows where .flag is {}. | FixIn EdgeQL, any = comparison with an empty set {} yields {}. Always write .owner ?= global caller and (.archived ?= true) rather than =. |
| Broken intermediate link hop | The user is signed in and the row exists, but select returns []. | FixRun napalm explain-access below to see the exact link step where the traversal came back empty. |
# Pitfall: when global caller is {}, (x = {}) evaluates to {} (empty), NOT true or false.# Always use ?= (coalescing equality) when comparing against optional globals or optional links.access policy author_can_read allow select using (.author.identity ?= global caller);Explanations for a hidden row#
Never add temporary debug queries or weaken access policies to find out why a customer cannot see a record. Run napalm explain-access with the object’s UUID and --as <email|identity-id> or --key <key-id>.
Rule-by-rule trace without row values
napalm explain-access walks link paths such as .workspace.org.members.identity inside the engine and reports the first empty hop while keeping field values masked.
- Empty link steps
- Walks every step of
.workspace.org.members.identityand highlights the exact link that evaluated to{}for that object (".workspace.org.members is empty for this object"). - Zero data exposure
- Evaluates policy booleans and global presence inside the engine without ever returning the row’s private field values to the operator’s terminal.
- Org audit events
- Every
--ascheck records aprojectPersonAccessCheckedaudit event innapalm activityso person-level debugging is accountable.
Counting overall reach across every table#
Count the rows a user can read, update or delete across the entire database, or preview a service key’s reach before issuing the key.
napalm people ls acme maya@acme.conapalm people reach acme maya@acme.conapalm keys reach acme --new --read-onlySkipped updates and access policy errors#
Developers coming from SQL are often surprised when one update call returns [] silently while another fails with 400 query_failed (AccessPolicyError). That split comes from the two phases of allow update.
| Phase | Timing | On failure |
|---|---|---|
update read | Before modifying rows (filters candidate set) | On failureSilently skips rows the caller may not target, as with select and delete. update Note filter .id = $id returns [] without revealing whether $id exists. |
update write | After applying set { … } (validates new row state) | On failureAborts the transaction with AccessPolicyError, so a caller cannot move a row into another user’s account or into a state that fails the caller’s policy. |
insert | After constructing the new row | On failureAlways aborts with AccessPolicyError if no allow insert rule holds or any deny insert rule matches. |
To let an owner transfer ownership (so the post-update row no longer matches .owner ?= global caller), split allow update into separate update read and update write policies.
# Separate who may target existing rows (update read) from what the edited row must look like (update write).access policy author_can_transfer_ownership allow update read using (.owner ?= global caller); access policy valid_new_owner allow update write using (exists .owner);Rejected statements and required deployed queries#
Requests that step outside the Project API’s single-statement data sandbox or violate endpoint lockdown settings fail before execution with a structured error code.
| Error code | Common trigger | Resolution |
|---|---|---|
400 query_rejected | Referencing sys::*, cfg::*, schema::*, ext::auth::* or ext::ai::* directly in a query. ext::napalm::Job, ext::pgcrypto, ext::ai::search, ext::ai::hybrid_search and ext::ai::to_context are allowed. | ResolutionRead global caller (ext::auth::ClientTokenIdentity) or wrap controlled ext::auth::Identity lookups in a default:: schema function. Call POST /search (napalm.search) for hybrid AI search. |
400 query_rejected | Sending multiple semicolon-separated statements, DDL (create type), configure or set global. | ResolutionPOST /query runs one data-plane EdgeQL statement per request. Combine chained writes into a single atomic with … select statement. Run DDL via napalm schema push. |
403 deployed_query_required | Endpoint has --passthrough keys (or none) and a browser session called POST /query or an undeployed SDK. | ResolutionRun napalm queries push <project> and regenerate your client with napalm generate <project> --deployed so requests call POST /query/{name} with { variables } only. |
403 nothing_found | Calling an action (/query/{actionName}) whose gatekeeper query returned 0 rows for the caller. | ResolutionVerify the record exists, passes the caller’s select policies and matches all filter conditions in the action’s .edgeql file. |
403 read_only | Calling a write action with a --read-only service key, a read-only OAuth 2.1 grant or a read-only endpoint. A write statement from the same caller fails with query_failed and the type DisabledCapabilityError. | ResolutionUse a read-write credential, or pass "is_dry_run": true if you only want a rollback preview. |
Stale reads after a write#
If a user creates or edits a record and a page refresh 100 milliseconds later shows the old state, the second request omitted Napalm-Bookmark. The read came from an engine cache (up to 1 s old, reported in Napalm-Freshness) or from a replica that had not yet caught up to that commit.
Bookmark-verified replica routing
Passing Napalm-Bookmark skips stale engine cache entries and routes reads only to a replica caught up to that commit position, falling back to the primary when replicas lag.
- Single-process SDKs
- Pass
fetch: napalm.fetch(TypeScript) orhttpClient: napalm.httpClient(Dart) to your generated OpenAPI client.NapalmClientattaches and updatesNapalm-Bookmarkautomatically. - SSR and Server Actions
- Persist
napalm.bookmarkin a cookie after Server Actions and passnapalm.reach(cookieBookmark)when constructing your RSC client. See the Next.js and React guide. - Webhooks and workers
- Pass
delivery.position(fromNapalm-Position) intonapalm.reach(delivery.position)before querying back.
Blocked schema pushes and slow policy scans#
Schema pushes and access-policy plans run three operational checks as your schema and data volume grow.
Migration refused because of a deployed query#
napalm schema push compiles your schema migration and recompiles every deployed query in the same transaction. When renaming or dropping a field breaks an existing deployed query, update the corresponding dbschema/ file locally and run napalm schema push. The CLI uploads the schema and your updated dbschema/queries/ directory together atomically.
Adding a required field to a populated table#
napalm schema push stops with The migration needs a decision first when a migration adds a required property or link without a default to an existing type, or makes an optional field required. Existing rows need a value during the migration. A schema default assigns one constant value, whereas a fill decision in dbschema/decisions.yaml computes each row’s value in the same push. Non-interactive runs print the required YAML snippet, while terminal runs prompt for the expression and offer to save the file.
# A new required property on an existing type# Option A: a fixed default populates existing objects in the same pushrequired priority: int16 { default := 0;}; # Option B: when each object's value comes from existing fields, add the property with a placeholder# default, backfill real values with an update statement, then drop the default in a second push.# Option C: a fill gives each existing object a value from the object's own fields, in the same pushdecisions: - field: Note.summary kind: fill expression: ".body[:120] ?? ''"Live schema changes walks through option B using a backfill key. Because a fill rewrites every existing row inside the migration transaction while writes to that type wait, option B is better suited to large tables. Answer what a migration asks covers dbschema/decisions.yaml.
Profiling access-policy CPU and missing indexes#
Access policies compile into SQL joins and semi-joins, so an unindexed filter inside an access policy can trigger sequential scans as tables grow. Run napalm insights or call the MCP explain_query tool to inspect mean latency, replica read ratios, per-policy execution share and replica-verified index recommendations.
Per-policy latency and replica telemetry
napalm insights isolates policy CPU share, flags 0% replica ratios caused by volatile functions and suggests planner-verified napalm schema index commands.
| Observation in insights | Root cause | Fix |
|---|---|---|
High policy percentage (> 40%) | A policy traverses a membership or grant table without a composite index on the join and caller columns. | FixApply the suggested napalm schema index command and mirror the index on ((...)) line in dbschema/default.gel. |
0% replica ratio on a read query | The statement calls a volatile function (such as uuid_generate_v4() or clock_timestamp()), forcing execution onto the primary. | FixReplace volatile calls in reads with stable functions such as datetime_of_statement() so read replicas can serve the query. |
| Rising mean latency on paginated lists | Using offset on large tables scans and policy-checks every skipped page before returning limit rows. | FixSwitch to tuple keyset pagination ((.created, .id) < (...)) backed by a composite index. See Queries and mutations. |
| Slow aggregate counts on dashboards | Recomputing unfiltered count(.items) across hundreds of thousands of linked rows on every page load. | FixBound counts to recent windows or maintain a counter column updated inside write transactions. |
# Sort slowest statements by total execution time, call volume or mean latencynapalm insights acme --by time --days 7 # Preview and apply a planner-verified composite index on mainnapalm schema index acme Membership org identityError codes#
Every code below and its HTTP status come from the API reference, while the final group lists statusless codes sent in live stream error frames. Sign-in provider errors pass through POST /sign-in/{action} unchanged and are listed in Sign-in for your app.
Malformed and oversized requests#
| Status | Code | Meaning | Explained in |
|---|---|---|---|
| 400 | action_not_live | MeaningThe query is an action, whose rows go only to the handler. | Explained inRunning queries |
| 400 | backups_not_configured | MeaningA cluster that keeps no backups. | Explained inDistribution |
| 400 | dry_run_unsupported | MeaningA dry run of something other than one insert, update or delete whose result is the changed objects. | Explained inProject API |
| 400 | expired_request | MeaningThe request is older than 15 minutes, or Napalm never signed the request. | Explained inSign-in |
| 400 | invalid_bookmark | MeaningThe bookmark isn’t well formed. | Explained inProject API |
| 400 | invalid_bundle | MeaningThe tar holds an entry outside app/ or an entry that isn’t a plain file or a directory. | Explained inActions, handlers & schedules |
| 400 | invalid_image | MeaningThe image can’t be read at the published location. | Explained inActions, handlers & schedules |
| 400 | invalid_parts | Meaningfirst is below 1, count isn’t between 1 and 1,000, sha256 isn’t a SHA-256 for each requested part, or stored isn’t true or false. | Explained inLimits |
| 400 | invalid_request | MeaningA value is out of range or malformed. | Explained inProject API |
| 400 | invalid_schedule | MeaningNapalm can’t schedule the cron or the time zone. | Explained inActions, handlers & schedules |
| 400 | no_shard_in_region | MeaningNo shard of the branch runs in the region. | Explained inScale & recovery |
| 400 | outside_region | MeaningA root kept in a region, sent to a shard elsewhere. | Explained inDistribution |
| 400 | query_failed | MeaningThe engine couldn’t run the statement. | Explained inProject API |
| 400 | query_rejected | MeaningThe statement isn’t one data statement the API runs. | Explained inProject API |
| 400 | schema_invalid | MeaningThe engine refused the schema, with the engine’s type and message. | Explained inControl API |
| 400 | types_required | MeaningNo types for a project that doesn’t share the schema. | Explained inProject API |
| 413 | presence_too_large | MeaningA state over 4 KiB or a message over 16 KiB. | Explained inProject API |
| 413 | request_too_large | MeaningThe body is over 1 MiB. | Explained inProject API |
| 413 | result_too_large | MeaningThe answer is over 16 MiB. | Explained inProject API |
| 422 | ask_unanswered | MeaningNo statement answered the question in four tries. | Explained inProject API |
Credentials, access and spend#
| Status | Code | Meaning | Explained in |
|---|---|---|---|
| 401 | invalid_client | MeaningNo client_id, a wrong secret or a handler without the action’s key. | Explained inA backend service |
| 401 | invalid_key | MeaningA service key that isn’t this project’s, or has expired or been revoked. | Explained inProject API |
| 401 | invalid_session | MeaningA session Napalm couldn’t verify, or whose person no longer exists. | Explained inProject API |
| 401 | invalid_token | MeaningThe bearer token isn’t the assertion of a job’s call from this project. | Explained inAgent access & grants |
| 401 | unauthorized | MeaningNo token, two tokens, or an unknown, expired or revoked token. | Explained inProject API |
| 402 | monthly_cap_reached | MeaningThe machines would cost more than the cap the org’s managers set below the limit (POST /org/spend-limits). | Explained inControl API |
| 402 | monthly_limit_reached | MeaningThe org’s machines plus this month’s metered extras so far would cost more per month than the org’s limit, at the pricing page’s prices. | Explained inControl API |
| 402 | payment_failed | MeaningThe card declined the upfront charge for the rest of the month. | Explained inClusters |
| 402 | payment_method_required | MeaningThe org has no card. | Explained inClusters |
| 402 | payment_overdue | MeaningA payment from the org failed and is still owed. | Explained inControl API |
| 403 | deployed_query_required | MeaningA caller outside the project’s passthrough sent a statement or question of the caller’s own. | Explained inProject API |
| 403 | forbidden | MeaningA browser at an origin the project doesn’t allow. | Explained inProject API |
| 403 | manage_scope_required | MeaningA read token asked for a change. | Explained inControl API |
| 403 | nothing_found | MeaningIf the statement finds no rows, the handler isn’t called and the call answers 403 nothing_found. | Explained inProject API |
| 403 | read_only | MeaningA read-only caller is refused an action that changes data (403 read_only). | Explained inProject API |
Missing records and conflicts#
| Status | Code | Meaning | Explained in |
|---|---|---|---|
| 404 | no_file | MeaningThe upload’s file has been deleted. | Explained inFile uploads |
| 404 | no_lost_gap | MeaningThe bookmark names no history the branch left. | Explained inProjects |
| 404 | not_found | MeaningNo such record in your org. | Explained inProject API |
| 404 | root_not_found | MeaningThe branch has no object with that id. | Explained in— |
| 404 | unknown_upload | MeaningNo upload has this token. | Explained inFile uploads |
| 409 | action_key_missing | MeaningAn action was called before the database had a key to sign action calls. | Explained inRunning queries |
| 409 | ask_not_configured | MeaningNo model is configured for questions on this project. | Explained inProject API |
| 409 | backups_not_configured | MeaningThe cluster keeps no backups. | Explained inControl API |
| 409 | branch_copy_failed | MeaningThe operation that makes the branch failed within the wait. | Explained inControl API |
| 409 | branch_distributed | MeaningThe branch is spread over more than one shard. | Explained inProject API |
| 409 | branch_moved_after_moment | MeaningThe branches in branches were moved onto or off the shard, copied or placed after the moment. | Explained inSchema & branches |
| 409 | branch_newer_than_moment | MeaningThe branches in branches are on the shard and were made after the moment, so restoring would lose those branches. | Explained inSchema & branches |
| 409 | change_log_not_configured | MeaningThe project’s cluster keeps no change log. | Explained inProject API |
| 409 | cluster_busy | MeaningAnother operation is running on the cluster, or a hold that isn’t the org’s keeps the cluster busy. | Explained inControl API |
| 409 | cluster_unavailable | MeaningNapalm couldn’t reach the project’s cluster. | Explained inControl API |
| 409 | conflict | MeaningThe change conflicts with an existing record. | Explained inControl API |
| 409 | files_not_configured | MeaningThe cluster has no file storage. | Explained inControl API |
| 409 | github_not_configured | MeaningThis control service has no GitHub App. | Explained inControl API |
| 409 | grant_expired | MeaningThe grant is past expireTime. | Explained inProjects |
| 409 | grant_refused | MeaningThe grant holds a global the branch’s grantGlobals no longer name, so the project refuses each call under the grant. | Explained inProjects |
| 409 | grant_revoked | MeaningThe grant is revoked. | Explained inProjects |
| 409 | handlers_not_available | MeaningHosted handlers aren’t offered here. | Explained inActions, handlers & schedules |
| 409 | host_not_allowed | MeaningThe URL’s host isn’t one of the branch’s allowed hosts (POST /). | Explained inProjects |
| 409 | host_taken | MeaningAnother bucket is using or waiting for the host, or the host is one of Napalm’s own. | Explained inControl API |
| 409 | job_not_failed | MeaningThe job is neither failed nor cancelled. | Explained inActions, handlers & schedules |
| 409 | job_not_pending | MeaningThe job is neither waiting nor running with its handler holding the work. | Explained inActions, handlers & schedules |
| 409 | job_run_ended | MeaningThe run is over. | Explained inJobs & schedules |
| 409 | jobs_not_available | MeaningThe branch’s cluster runs a version from before jobs. | Explained inActions, handlers & schedules |
| 409 | key_globals_not_available | MeaningThe request names globals while keys with globals of their own aren’t offered. | Explained inProjects |
| 409 | key_limit_reached | MeaningThe branch has reached the limit of 500 live keys. | Explained inControl API |
| 409 | label_taken | MeaningAnother cluster has that label. | Explained inControl API |
| 409 | model_not_configured | MeaningThe statement searches by words, and the type’s index has no model provider to embed the words. | Explained inProject API |
| 409 | not_a_root | MeaningThe id names a row under a root or a row of a type that no root owns. | Explained in— |
| 409 | not_accepted | MeaningThe file’s type can’t hold the bytes. | Explained inReact, Vite & single-page apps |
| 409 | not_multipart | MeaningThe upload is a single PUT, or the upload’s bytes are already checked. | Explained inFile uploads |
| 409 | not_uploaded | MeaningNothing is stored yet, or a large file’s parts were never requested. | Explained inSchema & extensions |
| 409 | parts_incomplete | MeaningNot every planned part arrived whole. | Explained inFile uploads |
| 409 | paused | MeaningThe webhook is paused. | Explained inProjects |
| 409 | replica_commits_not_available | MeaningThis choice isn’t offered yet (GET /rollout). | Explained in— |
| 409 | scale_out_not_available | MeaningMore than one replica or two engines isn’t offered yet (GET /rollout). | Explained inClusters |
| 409 | search_not_configured | MeaningThe cluster has no search bucket. | Explained inClusters |
| 409 | shard_holds_branches | MeaningotherBranches isn’t exactly the other branches on the shard. | Explained inSchema & branches |
| 409 | size_mismatch | MeaningThe bytes aren’t the size the insert declared. | Explained inSchema & extensions |
| 409 | step_limit_reached | MeaningThe job already keeps 1,000 steps, and none of them has this name. | Explained inJobs & schedules |
| 409 | type_mismatch | MeaningA public file’s bytes aren’t the declared type. | Explained inSchema & extensions |
| 409 | volume_full | MeaningThe cluster’s volume has no room for the branch. | Explained inControl API |
| 409 | webhook_limit_reached | MeaningThe branch has reached the limit of 128 webhooks. | Explained inProjects |
| 410 | bookmark_too_old | MeaningThe change log can’t say everything that changed after the bookmark. | Explained inRunning queries |
| 410 | expired_upload | MeaningThe upload expired before the bytes were checked. | Explained inSchema & extensions |
| 410 | root_erased | MeaningAn erasure took the root. | Explained in— |
Rate and count limits#
| Status | Code | Meaning | Explained in |
|---|---|---|---|
| 429 | call_budget_reached | MeaningA key or an agent’s grant past the call budget gets 429 call_budget_reached with Retry-After on every route. | Explained inSessions & keys |
| 429 | job_limit_reached | MeaningThe statement queued a job past the limit of 10,000 waiting jobs per caller. | Explained inProject API |
| 429 | live_limit_reached | MeaningThe project already holds 1,000 live subscriptions for each GiB of engine memory, across all streams. | Explained inProject API |
| 429 | presence_limit_reached | MeaningMore than 16 joined rooms or 256 watched rooms on the stream. | Explained inProject API |
| 429 | presence_rate_reached | MeaningMore than 32 messages a second from this caller to the room. | Explained inProject API |
| 429 | rate_limited | MeaningThe branch has taken its 100 dry runs, tests, checks and plans this minute. | Explained inRunning queries |
Failures and unavailable services#
| Status | Code | Meaning | Explained in |
|---|---|---|---|
| 424 | model_unavailable | MeaningA search’s words couldn’t be embedded because the model’s provider didn’t answer. | Explained inProject API |
| 500 | internal_error | MeaningSomething failed on Napalm’s side. | Explained inControl API |
| 500 | roots_failed | MeaningThe engine couldn’t work out the roots. | Explained inDistribution |
| 502 | action_unreachable | MeaningThe action’s handler couldn’t be reached, or sent nothing within the time limit. | Explained inProject API |
| 502 | answer_too_large | MeaningThe handler’s whole answer is over 1 MiB. | Explained inProject API |
| 502 | invalid_stream | MeaningThe handler answered a stream with a status other than 200. | Explained inActions |
| 503 | billing_unavailable | MeaningThe billing service couldn’t process the upfront charge right now, so nothing was charged or made. | Explained inClusters |
| 503 | github_unavailable | MeaningGitHub didn’t answer. | Explained inControl API |
| 503 | live_unavailable | MeaningThe branch can’t stream changes yet. | Explained inProject API |
| 503 | log_unavailable | MeaningThe change log can’t be read right now. | Explained inProject API |
| 503 | project_unavailable | MeaningThe project didn’t answer within 60 seconds. | Explained inProject API |
| 504 | ask_timeout | MeaningThe question took more than 120 seconds with the model’s turns. | Explained inProject API |
Live stream errors#
| Code | Meaning | Explained in |
|---|---|---|
api_off | key_revoked, session_ended and api_off end the stream for good. | Explained inLive queries & presence |
channel_full | For a room, not_found (the caller can’t read the object), channel_full (the room holds 200 members) or resumed (a newer stream took the member’s place). | Explained inLive queries |
engine_stopping | engine_stopping, too_slow and project_unavailable ask you to reconnect. | Explained inLive queries & presence |
key_revoked | key_revoked, session_ended and api_off end the stream for good. | Explained inLive queries & presence |
resumed | For a room, not_found (the caller can’t read the object), channel_full (the room holds 200 members) or resumed (a newer stream took the member’s place). | Explained inLive queries |
schema_changed | For a subscription: deployed_query_required, not_found, action_not_live, query_rejected, query_failed, result_too_large, schema_changed or project_unavailable. | Explained inLive queries |
session_ended | The session’s tokens are refused from then on, and the session’s open streams end with session_ended. | Explained inLive queries & presence |
token_expired | token_expired ends a session’s stream 30 seconds before the session’s token runs out, so the client reconnects with the next token. | Explained inLive queries |
too_slow | engine_stopping, too_slow and project_unavailable ask you to reconnect. | Explained inLive queries & presence |