Skip to content

db import cannot execute documented SQL verification files #273

Description

@agent-zhang-beihai

What happens

On Windows, using db import with a transactional SQL verification file routes to the database backup-import endpoint, returns FORBIDDEN, then can terminate with a libuv assertion. The same SQL DO block succeeds through db query after removing the outer transaction statements.

Command

npx @insforge/cli@0.2.1 db import tests/database/001-schema.sql

Error

FORBIDDEN from /api/database/advance/import followed by a Windows libuv assertion

Expected

A repository SQL verification file should execute as SQL, or the CLI should clearly reject this use without crashing.

Workaround

Read the SQL file, remove only its outer BEGIN/ROLLBACK transaction controls, and send the resulting DO statement through db query --unrestricted.

Triage finding

Triage judged this fixable.

In CLI/src/commands/db/import.ts:40-41 parse the error body as {error, message, nextActions} and throw new CLIError(err.message ?? err.error ?? \Import failed: ${res.status}`, 1, err.error, res.status)appendingnextActions— matchingsrc/lib/api/oss.ts:268-271— so users see "Transaction control statements are not allowed." instead of bare "FORBIDDEN"; add a "Restrictions" section toinsforge-skills/skills/insforge-cli/references/database/import.md(mirroringquery.md:47-51) stating that import files must not contain BEGIN/COMMIT/ROLLBACK/SAVEPOINTbecause the server wraps the whole file in its own transaction, and pointing rollback-rehearsal verification files atdb querywith aDOblock; verify with a newsrc/commands/db/import.test.tsstubbingfetchto return a 403{error:'FORBIDDEN',message:'Transaction control statements are not allowed.'}` and asserting the CLI surfaces the message (note in the issue: crash half is CLI#236, guard-relaxation question is CLI#263).

Suggested fix

From automated triage — a starting point, not a verified plan.

In CLI/src/commands/db/import.ts:40-41 parse the error body as {error, message, nextActions} and throw new CLIError(err.message ?? err.error ?? \Import failed: ${res.status}`, 1, err.error, res.status)appendingnextActions— matchingsrc/lib/api/oss.ts:268-271— so users see "Transaction control statements are not allowed." instead of bare "FORBIDDEN"; add a "Restrictions" section toinsforge-skills/skills/insforge-cli/references/database/import.md(mirroringquery.md:47-51) stating that import files must not contain BEGIN/COMMIT/ROLLBACK/SAVEPOINTbecause the server wraps the whole file in its own transaction, and pointing rollback-rehearsal verification files atdb querywith aDOblock; verify with a newsrc/commands/db/import.test.tsstubbingfetchto return a 403{error:'FORBIDDEN',message:'Transaction control statements are not allowed.'}` and asserting the CLI surfaces the message (note in the issue: crash half is CLI#236, guard-relaxation question is CLI#263).


Component cli · severity major · CLI 0.2.1 · win32 10.0.26200

Filed automatically from user feedback.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions