Skip to content

Errors ​

Every CLI error code and every schema issue code, generated from the source (CliError codes in src/cli/**, issue codes in src/cli/schema-check.ts). Walkthroughs: Troubleshooting.

There are two kinds:

  • CLI errors stop the command. They have a stable code, a message and usually a hint; in --json mode they are in error. Exit code 1 unless noted.
  • Schema issues are found by the static checks that validate, generate, diff and push run before producing SQL. Each has severity, code, path (e.g. posts.policies.update), message and usually hint. Any issue with severity error makes the command fail with SCHEMA_VALIDATION_FAILED and the full list in issues.
ts
interface SchemaIssue {
  severity: 'error' | 'warning';
  code: string;
  path: string;
  message: string;
  hint?: string;
}

CLI errors ​

Usage ​

CodeCommandsMeaningFix
UNKNOWN_COMMANDanyThe first argument is not a command.Use the suggested command; accessnexus help lists them.
UNKNOWN_FLAGanyA flag is not accepted by this command.Use the suggested flag; <command> --help lists them.
UNEXPECTED_ARGUMENTanyA positional argument was passed; commands take flags only.Prefix it with --, or remove it.
MISSING_FLAG_VALUEanyA string flag has no value (end of input, or the next token starts with --).--flag value or --flag=value.
INVALID_FLAG_VALUEanyA boolean flag was given a value (--json=true).Pass the flag alone.
INVALID_FLAGSgenerate, diff, push, seed--sql-only together with --sdk-only, or --target whose adapter differs from --adapter.Pass at most one of the pair; pass only --target.
MISSING_ARGUMENTmigration dataThe data migration has no name.npx accessnexus migration data <name>, e.g. backfill_task_org.

Config and file loading ​

CodeCommandsMeaningFix
CONFIG_NOT_FOUNDall except init--config <path> does not exist.Fix the path, or drop --config.
CONFIG_INVALIDall except initThe config file does not export an object.export default defineConfig({ ... }).
CONFIG_LOAD_FAILEDall except initThe config threw while running, or imports a module that cannot be found.Fix the named import or error; install a missing package.
SCHEMA_NOT_FOUNDvalidate, generate, diff, push, seedNo schema file at the resolved path.accessnexus init --yes, --schema <path>, or schema in the config.
SCHEMA_NO_DEFAULT_EXPORTsameThe schema file has no default export.End it with export default defineSchema({ ... }).
SCHEMA_LOAD_FAILEDsameThe schema threw while running, or imports a module that cannot be found.Fix the named import or error.
SCHEMA_INVALIDsameA builder threw: defineSchema (bad identifier, unknown primary key or reference column, bad or dangling reference) or definePermissions (unknown role, tenant scope without tenant config, unknown resource, missing ownerColumn / tenantColumn / roleColumn).Fix the definition named in the message. See definePermissions errors.
SCHEMA_VALIDATION_FAILEDsameThe static checks found at least one issue with severity error.Fix each entry of issues at its path as its hint says. See Schema issues.
SEED_LOAD_FAILEDseed, push --seedThe seed file threw while running, or imports a module that cannot be found.Fix the named import or error.
MODULE_SYNTAX_ERRORany that loads a fileThe config, schema or seed file does not compile; the message has file:line:column.Fix the syntax or TypeScript error.
TS_LOADER_MISSINGany that loads a fileesbuild is not available and Node cannot load the TypeScript file natively.Reinstall (npm install -D accessnexus), or use Node.js >= 22.18.

Generated output ​

CodeCommandsMeaningFix
GENERATED_OUT_OF_DATEdiff --check, pushGenerated files differ from what the schema produces. The JSON keeps the diff (diff) or stale (push).Review accessnexus diff, run accessnexus generate, retry.
NOTHING_TO_PUSHpushNo .sql files in the output folders.Run generate first, or point --output / the config at the generated folder.

Database and push ​

CodeCommandsMeaningFix
DB_URL_MISSINGpush, seedNo database URL from --url (alias --db-url), dbUrlEnv, ACCESSNEXUS_DB_URL, SUPABASE_DB_URL or DATABASE_URL.Pass --url or set one of them (shell, .env, .env.local). Use --dry-run to preview without a database.
PG_DRIVER_MISSINGpush, seed, init --db-urlThe optional pg peer dependency is not installed (or exports no Client).npm install -D pg.
DB_CONNECTION_FAILEDpush, seed, init --db-urlConnection failed or timed out (10 s default).Check URL, password and network. Supabase: "Session pooler" string. Local: ?sslmode=disable. Timeout: ACCESSNEXUS_DB_CONNECT_TIMEOUT=<seconds>.
PUSH_ROLE_NO_BYPASSRLSpushThe SQL contains SECURITY DEFINER helpers, but the connected role does not bypass RLS. Nothing applied.Connect as postgres, or ALTER ROLE <role> BYPASSRLS as a superuser.
DESTRUCTIVE_MIGRATIONpushA pending migration drops a table, column or type, truncates, or changes a column type. Nothing applied; destructive lists the statements.A rename: rename in the schema. Intended loss: back up, then push --allow-destructive.
FOREIGN_POLICIESpushA table the schema manages has RLS policies whose names are not <prefix>_<table>_<op> (not generated by AccessNexus). Permissive policies OR together, so they would keep granting access. Nothing applied; the message and foreignPolicies list table + policy.Port any rule still needed into the schema, review, then push --replace-foreign-policies (drops them in the push transaction). See Existing project.
FOREIGN_TRIGGERSpushA table the schema manages has triggers whose names are not <prefix>_<table>_... (not generated by AccessNexus). They would fire next to the generated ones — after init --db-url the original and its imported copy would both run. Nothing applied; foreignTriggers lists them.Port any trigger still needed into the schema (trigger.custom), review, then push --replace-foreign-triggers.
MIGRATION_DRIFTpushAn already-applied migration file was edited. The push was rolled back.Restore the file, change the schema, run generate for a new __changes migration.
PUSH_FAILEDpushPostgres rejected a file (message has the SQL error; failed names it). The push runs in one transaction, so all of it was rolled back: applied is [] and rolledBack lists the files that had run.Fix the cause in the schema (or the database state), generate, push again.
PUSH_WOULD_FAILdiff --against-db, push --dry-runThe rehearsal of the push was rejected by Postgres. failed has file, message, sqlState, line and statement; changes and wouldApply hold the partial plan up to the failure. Nothing was persisted.Fix the schema (or the database state) and plan again.
NOT_NULL_ON_NON_EMPTY_TABLEdiff --against-db, pushA pending migration adds a NOT NULL column without a default to a table that has rows (details: { table, column, rows }). Reported before Postgres fails with 23502; nothing applied.Add the column as nullable, backfill it with migration data, then make it required. migration discard replaces an unpushed migration. See Required column on a table with data.
LIVE_DB_CHANGESdiff --against-db --checkThe push would change the database. The plan (changes, riskyChanges) is in the result.Review it, then push; drop --check to only read the plan.
PUSH_LOCKEDdiff --against-dbA push holds the advisory lock; the live plan does not wait.Retry when the push finishes.

Migrations and test database ​

CodeCommandsMeaningFix
NO_MIGRATION_TO_DISCARDmigration discardThere is no migration snapshot in the migrations folder.Run generate first.
MIGRATION_ALREADY_APPLIEDmigration discardThe database applied the newest migration; applied migrations are immutable.Change the schema and generate a new __changes migration instead.
MIGRATION_DISCARD_NEEDS_DBmigration discardNo database URL, so the command cannot check that the migration was never applied.Pass --url / --target (or set the configured env var), or --force when no environment ever applied it.
MIGRATION_HISTORY_MISSINGmigration discardThe snapshot was written before 0.4.1 and has no record of the state before the migration. Nothing was deleted.Rebuild the previous snapshot by hand, or generate a new __changes migration that undoes the change.
DOCKER_NOT_FOUNDtest-dbThe docker command was not found.Install Docker (or start Docker Desktop) and run it again.
TEST_DB_PORT_IN_USEtest-db upSomething already listens on --port (default 55433).Pass another --port, or stop what uses it.
TEST_DB_START_FAILEDtest-db updocker run failed (port or container name in use), the database was not ready within 2 minutes, or preparing it for RLS tests failed.Free the port (--port) or pick another --name; check docker logs <name>.

Adapter and target ​

CodeCommandsMeaningFix
ADAPTER_NOT_FOUNDpush, seed--adapter <name> matches no configured adapter.Use one listed in the hint.
ADAPTER_AMBIGUOUSpush, seedconfig.adapters lists several adapters and none was chosen.Pass --adapter or --target.
ADAPTER_UNSUPPORTEDpush, seedThe selected adapter is not supabase.adapter: 'supabase'.
TARGET_NOT_FOUNDpush, seed--target <name> is not in config.targets.Use a listed target, or define it.
TARGET_INVALIDpush, seedThe target has no adapter string.Add adapter: 'supabase' to it.

Seed ​

CodeCommandsMeaningFix
SEED_NOT_FOUNDseed, push --seedThe seed file does not exist. With push --seed the SQL was already pushed.Create accessnexus.seed.ts, pass --seed <path>, or set seed in the config.
SEED_EMPTYseed, push --seedThe seed file's default export is not an object or has no tables.export default defineSeed(schema, { table: [rows] }).
SEED_REMOTE_BLOCKEDseed, push --seedThe URL is a hosted Supabase database (*.supabase.co, .com, .in).Use a local database, or --allow-remote-seed for a disposable project.
SEED_FAILEDseed, push --seedPostgres rejected the seed; it was rolled back.Run push first; make rows match the schema (unique keys, references).

With push --seed, any seed error keeps its own code, its message is prefixed with Push succeeded, but the seed failed:, and the JSON has seed.status: 'failed'.

init ​

CodeMeaningFix
INIT_NOT_INTERACTIVEinit would prompt, but stdin is not a TTY (or --json is set).Add --yes.
INIT_NEEDS_INPUTA question has no answer in non-interactive mode.Pass the flag named in the hint.
INIT_DETECT_FAILEDThe project could not be detected (usually no package.json).Run in the project root, npm init -y, or init --yes (creates a minimal package.json).

Internal ​

CodeExitMeaningFix
INTERNAL_ERROR2Any unexpected exception: an AccessNexus bug.Re-run with --verbose (or DEBUG=accessnexus) and report the stack trace.

Schema issues ​

Static checks run by validate, generate, diff and push. In Database mode, checks that need column lists are skipped, and UNKNOWN_TABLE is a warning instead of an error.

Schema structure ​

CodeSeverityPathMeaningFix
SCHEMA_NOT_AN_OBJECTerror(default export)The default export is not an object.export default defineSchema({ ... }).
SCHEMA_EMPTYwarning(schema)The schema has no tables.Add tables.
INVALID_TABLEerror<table>A table entry is not an object.<table>: table({ ... }).
RPC_IN_TABLESerror<table>An rpc() was placed among the tables.Pass it in defineSchema(tables, { rpcs: { ... } }).
UNKNOWN_TABLE_KEYerror<table>.<key>Unknown table option (it would be ignored, e.g. polices), or tables nested under a key such as tables:.Use the suggested option; valid: columns, primaryKey, compositePrimaryKey, references, onDelete, policies, triggers, enableRLS, indexes, softDelete, realtime.
MISSING_COLUMNSerror<table>.columnsSome tables declare columns and this one does not.Declare columns on every table (manual) or on none (Database mode).

Identifiers ​

CodeSeverityPathMeaningFix
INVALID_IDENTIFIERerrortable, column, rpcs.<name>, or triggerA table, column, RPC, lockColumns name or custom trigger name is not lowercase snake_case (one leading _ is allowed).Rename, e.g. user_profiles.
INVALID_PRIMARY_KEYerror<table>.compositePrimaryKey or <table>.softDeletecompositePrimaryKey lists fewer than two columns, is set together with primaryKey, or is combined with softDelete.Use primaryKey for one column, compositePrimaryKey for several, and a single key for soft delete.
RESERVED_IDENTIFIERerrortable or columnA table or column name is a reserved SQL keyword (order, user, group, ...). Identifiers are emitted unquoted.Rename, e.g. orders, user_id.

Columns ​

CodeSeverityPathMeaningFix
INVALID_COLUMNerror<table>.columns.<col>A column is neither a type string nor { type, ... }.email: 'text' or email: { type: 'text', unique: true }.
UNKNOWN_COLUMN_TYPEerror<table>.columns.<col>, rpcs.<name>.args.<arg>Unknown column or RPC argument type.Use a supported type; the hint suggests one for common aliases.
UNKNOWN_ENUMerror<table>.columns.<col>, rpcs.<name>...A type 'enum:<name>' names an enum that was not declared.const <name> = defineEnum('<name>', [...]) and defineSchema(tables, { enums: [<name>] }). See defineEnum.
INVALID_DEFAULTerror<table>.columns.<col>.defaultdefault is a bare word Postgres would read as a column name, or an enum default that is not one of the values.Quote literals inside the string: default: "'todo'"; functions as is: 'now()'.
NO_PRIMARY_KEYwarning<table>.primaryKeyThe table has no primaryKey.primaryKey: 'id' (needed by findById, update/delete by id, soft delete, seed upserts).
UNKNOWN_COLUMNerrorwhere the column is usedA column named in primaryKey, references, onDelete, softDelete, indexes, a policy rule (isOwner, belongsTo and its through keys and where, matchesField) or a trigger (updatedAt, softDelete, auditLog.columns, lockColumns) does not exist.Use a listed column, or add it to columns.

Keys and references ​

CodeSeverityPathMeaningFix
INVALID_REFERENCEerror<table>.references.<col>Not table.column or schema.table.column.'profiles.id', 'auth.users.id'.
UNKNOWN_TABLEerror (manual), warning (Database)reference, policy or trigger pathA reference, a belongsTo through.table, a belongsTo without through (needs profiles), or an auditLog target names a table not in the schema.Define the table, fix the spelling, or use schema.table.column for tables outside public.
INVALID_ON_DELETEerror<table>.columns.<col> or <table>.onDelete.<col>Unknown action, onDelete on a column without references, or 'set null' on a NOT NULL column.Use 'cascade' | 'set null' | 'restrict' | 'no action'; add references; make the column nullable.
CASCADE_INTO_SOFT_DELETEerror<table>.onDelete.<col>onDelete: 'cascade' on a soft-delete table: the children would keep pointing at a deleted parent.'restrict' (soft-delete children first), 'set null', or drop softDelete.

RLS and policies ​

CodeSeverityPathMeaningFix
NO_POLICIESwarning<table>.policiesNo policies: RLS is on, so the API (anon and signed-in) can neither read nor write the table.Add policies if the client uses the table; keep it for server-only tables (or policy.none() per operation).
RLS_DISABLEDwarning<table>.enableRLSenableRLS: false: anyone with the anon key can read and write the table.Remove enableRLS: false and add policies.
RLS_DISABLED_WITH_POLICIESerror<table>.enableRLSenableRLS: false together with policies.Remove enableRLS: false.
INVALID_POLICIESerror<table>.policiespolicies is not an object.{ select: policy.isAuthenticated() }.
UNKNOWN_POLICY_OPERATIONerror<table>.policies.<op>Key is not select, insert, update, delete or all (e.g. read, create).Use the SQL operation names, or all for one rule on every operation; read/create belong in definePermissions.
INVALID_POLICY_RULEerror<table>.policies.<op>Not built with policy.* (e.g. 'public'), hasRole without a role, or custom with an empty expression.policy.public(), policy.hasRole('admin'), a non-empty SQL expression.
UNKNOWN_POLICY_KINDerror<table>.policies.<op>A rule object has an unknown kind.Build rules with policy.*.
EMPTY_COMBINATORerror<table>.policies.<op>policy.any([]) or policy.all([]).Pass at least one rule, or use policy.none().
OWNER_COLUMN_NOT_UUIDerror<table>.policies.<op>policy.isOwner(col) on a non-uuid column.Make the column uuid.
INVALID_ENUM_VALUEerror<table>.policies.<op>A belongsTo through.where value is not a value of that enum column (e.g. a misspelled role).Use one of the listed values.

Security warnings and errors ​

CodeSeverityPathMeaningFix
PUBLIC_WRITEwarning<table>.policies.<insert|update|delete>policy.public() lets anonymous visitors write.isAuthenticated(), isOwner(col), a tenant rule, or policy.none(). Keep public() only for a deliberate anonymous form, combined with a check.
USER_ROW_INSERT_OPENwarning<table>.policies.insertThe primary key references auth.users.id, but insert is isAuthenticated() or public(): anyone can create another user's row.insert: policy.isOwner('<pk>').
GLOBAL_ROLE_IN_TENANT_TABLEwarning<table>.policies.<op>The table checks tenant membership but also uses a global app role (hasRole or a role array).For org/team roles use { scope: 'tenant', roles } or belongsTo(..., { where: { role } }).
TENANT_PARENT_UNCHECKEDwarning<table>.references.<col>A tenant-scoped row references another tenant-scoped table and nothing checks they are in the same tenant (foreign keys ignore RLS).Add trigger.sameTenant({ column, references, tenantColumn }) (the hint spells it out), and trigger.lockColumns on the tenant column. See sameTenant.
BELONGS_TO_PROFILE_WRITABLEerror<table>.policies.<op>belongsTo(col) without through trusts profiles.<col>, but users can insert profiles or update that column (or profiles has RLS off).Use through (membership table), or make profiles.<col> server-written: insert: policy.none() and trigger.lockColumns({ columns: ['<col>'] }).
UNWRAPPED_AUTH_CALLwarningpolicy, lockColumns trigger or rpcs.<name>.bodyA bare auth.uid(), auth.jwt() or auth.role() in policy.custom, a lockColumns unless, or an RPC body is re-evaluated per row.Write (SELECT auth.uid()).

Migration SQL ​

CodeSeverityPathMeaningFix
NOT_NULL_COLUMN_ADDEDwarning<table>.columns.<col>Reported by generate and diff (in warnings), not by validate: a new migration adds a NOT NULL column without a default to an existing table, so push fails when the table has rows.Give it a default, or add it nullable, backfill with migration data, then make it required. See Required column on a table with data.
SQL_REJECTEDerrorrpcs.<name>, <table>.triggers[<i>], <table>.policies.<op> (or the file)Reported by validate --against-db: Postgres rejected the SQL generated for that schema item (a policy.custom, trigger.custom body, RPC body, check or default). The command fails with SCHEMA_VALIDATION_FAILED.Fix the SQL in that part of the schema and run validate --against-db again. Nothing was persisted.

Triggers ​

CodeSeverityPathMeaningFix
INVALID_TRIGGERSerror<table>.triggerstriggers is not an array.triggers: [trigger.updatedAt('updated_at')].
INVALID_TRIGGERerror<table>.triggers[<i>]Not built with trigger.*; unknown kind; lockColumns without exactly one of columns / except; custom with no events, an unknown event, an empty functionBody, or security not 'invoker'/'definer'; a missing or wrong option of keepAtLeastOne (column, value, scope, a single primaryKey on the table), sameTenant (column, references, tenantColumn), memberOfTenant (column, tenant: { table, userColumn, tenantColumn }) or onAuthUserCreated (columns with a non-empty SQL expression per column).Fix the option named in the message.
DUPLICATE_TRIGGERerror<table>.triggers[<i>]Two triggers produce the same name on one table and would replace each other.Give each lockColumns / custom a distinct name; do not add trigger.softDelete when the table sets softDelete.
AUDIT_TABLE_MISMATCHerror<table>.triggers[<i>]The audit table lacks table_name, operation, old_data, new_data, changed_at, or has required columns the trigger never fills.Add those columns; make the others nullable or give them a default.
AUDIT_INSERT_OPENwarning<audit>.policies.insertThe audit table lets API users insert (forged entries). The trigger does not need it.insert: policy.none().

RPCs ​

CodeSeverityPathMeaningFix
INVALID_RPCerrorrpcs.<name>An entry of rpcs was not created with rpc(), or its volatility is not 'volatile' / 'stable' / 'immutable'.rpcs: { name: rpc({ ... }) }.
INVALID_RPC_RETURNSerrorrpcs.<name>.returnsreturns is an unknown type, an empty { table: {} }, a { setof } that is neither a schema table nor a column type, or another shape.A column type, 'void', { table: { col: 'type' } } or { setof: 'table_name' }. Result column names are checked as INVALID_IDENTIFIER, their types as UNKNOWN_COLUMN_TYPE.
RPC_VOLATILITY_CONFLICTerrorrpcs.<name>.volatilityimmutable contradicts volatility (e.g. immutable: true, volatility: 'stable').Keep only volatility.
INVALID_FUNCTION_SETerrorrpcs.<name>.set, <table>.triggers[<i>].setset is not an object, a key is not a configuration parameter name, or a value is not a string.set: { row_security: 'off' }.
SEARCH_PATH_PINNEDwarningrpcs.<name>.set.search_path, <table>.triggers[<i>].set.search_pathset.search_path differs from pg_catalog, public; generated functions always pin that value, so it is ignored.Remove it and schema-qualify anything outside public in the body.

RPCs also produce INVALID_IDENTIFIER (name or argument name), UNKNOWN_COLUMN_TYPE (argument type), INVALID_DEFAULT (an argument default that is not a SQL string, or an argument without default after one with a default) and UNWRAPPED_AUTH_CALL (body).

Realtime ​

CodeSeverityPathMeaningFix
INVALID_REALTIMEerror<table>.realtimerealtime is not true, false or { replicaIdentity: 'default' | 'full' }.Use one of those values.
REALTIME_NOT_READABLEwarning<table>.realtimeThe table is published but has no select policy (or policy.none()): Realtime delivers a change only to users whose SELECT policy shows the row, so nobody receives anything.Add policies.select.
REALTIME_RLS_DISABLEDwarning<table>.realtimeThe table is published with enableRLS: false: every subscriber, anon included, receives every row change.Remove enableRLS: false and add a select policy.
REALTIME_REPLICA_FULL_WITH_RLSwarning<table>.realtime.replicaIdentityreplicaIdentity: 'full' on a table with RLS: Supabase still sends only the primary key in old, so it only grows the WAL.Drop replicaIdentity.
INVALID_CHANNELerrorchannels.<name>...channels is not an object; a channel is not built with channel(); unknown option; bad topic (characters, no prefix, more than one parameter); table with no {param} in the topic or with a composite primary key; a {placeholder} in policy.custom that is not the topic parameter.Fix the option named in the message; topics look like 'lobby' or 'room:{id}'.
CHANNEL_RULE_NOT_SUPPORTEDerrorchannels.<name>.<broadcast|presence>.<receive|send>A rule that reads columns of a table row (isOwner, belongsTo, matchesField, withCheck): channel policies run on realtime.messages.true, isAuthenticated, public, none, hasRole, custom (with {param}), any / all; set table to require that the user can read the row.
CHANNEL_TABLE_NOT_READABLEwarningchannels.<name>.tableThe channel's table has no select policy, so the row check never passes.Add a select policy to the table.
CHANNEL_PUBLIC_SENDwarningchannels.<name>.<broadcast|presence>.sendAnonymous users can send or track presence.Use true or a narrower rule.
CHANNEL_CLOSEDwarningchannels.<name>The channel has no receive or send rule.Add rules, or remove the channel.

Channels also produce INVALID_IDENTIFIER (name not snake_case or longer than 40 characters), UNKNOWN_TABLE (table), INVALID_POLICY_RULE, EMPTY_COMBINATOR and UNWRAPPED_AUTH_CALL (policy.custom).

Edge Functions ​

CodeSeverityPathMeaningFix
INVALID_EDGE_FUNCTIONerrorfunctions...functions is not an object; a name is not lowercase letters/digits joined by - or _ (or longer than 63); two names share a camelCase SDK name; unknown option; auth is not 'user', 'publishable', 'secret', 'none' or a non-empty array of them with 'none' last; input / output is not an object (or, for output, a type or 'void').Fix the option named in the message.
EDGE_FUNCTION_PUBLICwarningfunctions.<name>.authThe function accepts calls without any credential (verify_jwt = false).Keep it for webhooks that verify a signature; otherwise use 'user' or 'secret'.
TABLE_NAME_CLASHerrorfunctions or channelsA table has the same name as the SDK's client.functions / client.channels, which the schema also declares.Rename the table.

Field names are checked as INVALID_IDENTIFIER and field / output types as UNKNOWN_COLUMN_TYPE (varchar(n) is accepted).

Released under the MIT License.