tursodatabase / tursodatabase/libsql

Get request to /dump endoint returns a dump that crahses on import

Open
#1,983 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
17.2k
Forks
531
Avg merge
1h 12m
Merged PRs (30d)
1

Description

Running turso inside a docker container.

Because turso db shell http://localhost:8080/ .dump doesn't create a dump (see libsql-shell-go issue), I tried to get it via /dump http endpoint.

curl -X GET -H "Authorization: Bearer $TURSO_AUTH_TOKEN" "${TURSO_DATABASE_URL%/}/dump" -o "$OUTPUT_FILE"
This successfully fetches a dump file, but an attempt to load it using turso db shell http://localhost:8080 < dump.sql crashes with this error:
Error: SQLite error: no such table: main.map_groups

I assume the crash is happening on this statement:

CREATE TABLE IF NOT EXISTS `levels` (
	`id` integer PRIMARY KEY NOT NULL,
	`map_group_id` integer NOT NULL,
	`name` text NOT NULL,
	FOREIGN KEY (`map_group_id`) REFERENCES `map_groups`(`id`) ON UPDATE no action ON DELETE cascade
);

levels table references map_groups table which appears to be created some time later. Moving map_groups CREATE TABLE above levels fixes the crash.

PRAGMA foreign_keys = OFF; is the first line in the dump. Import into regular sqlite proceeds without errors.

Versions

turso-cli v0.98.1
ghcr.io/tursodatabase/libsql-server:28294c9 (latest atm)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by fetching a dump from the /dump HTTP endpoint and importing it with turso db shell http://localhost:8080 < dump.sql; inspect the dump's table creation order around levels and map_groups. Done means the generated dump imports without the no such table: main.map_groups crash, while preserving the reported foreign-key behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.