warehouse: a relative SQLite file: URI still follows the working directory, and the fix is platform-dependent
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- bun, sqlite, typescript
調査の方向性
SQLiteファイルURI周辺のwarehouse接続処理から始め、issueで説明されている修正の試み #1204 と比較します。cwd/--dir を変更しながら、実際のデータベース1つとおとり1つで再現し、その後、実行時のURIモードプローブとSQLite専用の書き換え動作を追加します。完了条件は、一覧にあるすべての分岐が、提供対象プラットフォーム上のコンパイル済みバイナリのテストでカバーされ、おとりデータによって意図したデータベースが開かれることが実証されることです。
索引モデルが issue の本文から書いたものです。
説明
What happens
A connection configured with a relative SQLite file: URI follows the process working directory, so --dir can point it at a different database. On macOS this is a genuine instance of the #1203 defect class, and a nastier one: the create-on-open guard cannot catch it, because the failure is opening the wrong existing database rather than making a new empty one.
Reproduced on macOS with bun:sqlite, one real store and one decoy:
config: file:warehouse.db
cwd: <decoy dir>
opens: ["decoy_table"] ← the decoy, not the configured store
with an absolute rewrite:
config: file:/abs/path/warehouse.db
opens: ["zorbulax_ledger"] ← the intended store
Why it is not fixed in #1204
I implemented the rewrite in #1204 and then removed it, because it is platform-dependent in a way I could not verify across the shipped targets.
bun:sqlite's URI handling is not uniform. On macOS, file:warehouse.db is parsed as a URI (SQLITE_OPEN_URI behaviour): the reproduction above is real. On Linux CI the same test failed — the configured path opened nothing, which is consistent with file: being treated as a literal filename rather than a URI there. Windows was never verified at all, and it is a shipped build target (packages/opencode/script/build.ts).
That matters because the rewrite changes which database opens. Applying it on a platform where file: is a literal filename turns a working config into a broken one — precisely the class of bug #1203 is about. Shipping it half-verified would have been worse than leaving the exotic case alone.
The attempt also produced four separate regressions during review, each caught only by empirical testing, which is a fair signal about how much care this needs:
- Percent-encoded absolute paths.
file:%2Fvar%2Fwh.dbis absolute; SQLite decodes before opening. Treating it as relative produced a path that does not exist. file::memory:is SQLite's in-memory URI. Absolutizing it turned an in-memory database into a file on disk.- Case sensitivity. SQLite recognises only a lowercase
file:. A case-insensitive match rewroteFILE:warehouse.db, a literal filename, into a different path. - Special characters in the base directory. A project path containing a literal
%,?, or#is URI syntax and needs encoding before being joined.
What a fix needs
- Detect at runtime whether
bun:sqliteon the current platform actually honours URI mode — e.g. probenew Database("file::memory:", { readwrite: true, create: false })once, which succeeds only when URI parsing is active — and rewrite only when it does. - Decide relative-versus-absolute on the decoded path.
- Decline the exact
:memory:and decoded-colon-led forms. - Match the scheme case-sensitively.
- Percent-encode the base directory before joining.
- SQLite only. DuckDB reads
file:as an extension scheme and errors withExtension "file.duckdb_extension" not found, so a rewrite there dresses up a path that never worked. - Cover every branch with a compiled-binary test on each shipped platform, with a decoy database planted so a wrong resolution reads plausible wrong data rather than nothing.
Severity
Low in practice. No evidence any user writes file: URIs into connections.json; the ordinary relative path form, which is what #1203 reported, is fixed on every platform by #1204. Filing so the hole is recorded with its evidence rather than forgotten.
- 主要言語
- TypeScript
- スター
- 813
- フォーク
- 134
- 平均マージ
- 2日 3時間
- マージ済み PR(30日)
- 65
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
AltimateAI/altimate-code のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
AltimateAI/altimate-code#1359 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
AltimateAI/altimate-code#1323 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
AltimateAI/altimate-code#1288 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
AltimateAI/altimate-code#1285 ·
-
privacy: Altimate Base consent dialog no longer discloses persistent per-installation identifier オープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
AltimateAI/altimate-code#1284 ·
AltimateAI/altimate-code の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mksglu/context-mode#1200 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/claude-code#96687 ·
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
AOSSIE-Org/DebateAI#582 · コメント 2 件 ·