squad_state_list fails for root on adapter-backed backends: StateBackendStorageAdapter.toRelative() returns "." for squadDir
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 63/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
Rechercherichtung
Start in packages/squad-sdk/src/state-backend.ts and inspect StateBackendStorageAdapter.toRelative() alongside its list and directory methods. Then read packages/squad-sdk/src/tools/index.ts for normalizeStateToolDir() and the existing key validation. Add regression coverage for root listing while preserving traversal and file-operation rejection; done means the listed root entries are returned and the specified invalid paths still fail.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
squad_state_list with dir omitted (or "", or ".squad") fails on any backend routed through StateBackendStorageAdapter (observed with stateBackend: "two-layer"):
Failed to list state: State key must not contain . or .. path segments
squad_state_list {dir: "decisions"} works.
Environment
- squad CLI v1.0.1 (WinGet
bradygaster.Squad), Windows .squad/config.json→stateBackend: "two-layer";squad_state_health→State backend storage: StateBackendStorageAdapter- Source references below are from
main@ 89d6302576ce03b87fe0519235854c9e8638737f (bug still present)
Minimal repro
- Repo with
stateBackend: "two-layer"(ororphan/git-notes). - Run
squad state-mcp, callsquad_state_list {}. - Observe the error above.
Unit-level repro:
const adapter = new StateBackendStorageAdapter(new OrphanBranchBackend(repo), squadDir);
adapter.listSync(squadDir); // throws: State key must not contain . or .. path segments
Root cause
packages/squad-sdk/src/tools/index.tsnormalizeStateToolDir()correctly maps an omitted dir to"", then callsthis.storage.listSync(path.join(this.squadRoot, "")), i.e.listSync(squadRoot).packages/squad-sdk/src/state-backend.tsStateBackendStorageAdapter.toRelative()has:if (fileCmp === squadCmp) { return '.'; }- Every backend
list()runsnormalizeKey(relativeDir).normalizeKeyexplicitly allows""as root ("Empty string after normalization means root — valid for list() operations"), but"."is non-empty, sovalidateStateKey('.')throws.
The adapter emits a root sentinel the backends do not accept.
Suggested fix (keeps traversal rejection)
Do not relax validateStateKey. Map squadDir to "" only for list-shaped reads:
list/listSync/isDirectory/isDirectorySync: when the path resolves to squadDir, pass"".- Keep
"."(and therefore rejection) for file operations and especiallydeleteDir/deleteDirSync. Returning""there would turndeleteDir(squadDir)into a wipe of all state, andread("")on git backends could resolve to a tree object.
For example, add private toRelativeDir(p) { const r = this.toRelative(p); return r === '.' ? '' : r; } and use it in the four list methods.
Regression tests
adapter.listSync(squadDir)returns root entries for the orphan, git-notes, and two-layer backends.squad_state_list {}and{dir: ""}succeed.{dir: ".."},{dir: "a/../b"}, and{dir: "."}still fail with the. or ..error.adapter.deleteDirSync(squadDir)andadapter.readSync(squadDir)still throw.
Downstream report: OlyForge3D/PrintFarmer#3372
- Vorherrschende Sprache
- TypeScript
- Sterne
- 3.4k
- Forks
- 516
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 116
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/squad
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
vercel-labs/ui#809 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bot:ai-assisted component:platform-js status:untriaged
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 74/100
midnightntwrk/platform-js#38 ·
-
[bug] Second false positive on high-cost plugin alert: detection only compares patch entry id, community plugin dsh-auto | [bug] 高成本插件告警第二次误报:检测只比对 patch 条目 id,社区插件 dsh-auto-review 被认成 @deepseek-ai/dsh-experimental-auto-reviewEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ranxianglei/billion-context#7068 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
mybigday/whisper.rn#348 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
six-group/six-webcomponents#600 ·