vscode: migrate settings.json writer to full hujson AST manipulation
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Inizia da cmd/modern/root/open/jsonc.go e cmd/modern/root/open/vscode.go per tracciare l’attuale parsing di hujson, la costruzione dei profili e i percorsi di aggiornamento. Estendi cmd/modern/root/open/jsonc_test.go, incluso TestApplyJSONCSettingsUpdates_PreservesComments, per i commenti adiacenti a add e per connessione. Il lavoro è completato quando gli aggiornamenti diretti dell’AST hujson preservano i commenti, l’ordine e i campi non correlati per i profili nuovi ed esistenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Background
PR #688 added sqlcmd open vscode, which writes the user's settings.json to register a connection profile. The original implementation stripped JSONC comments and trailing commas, marshaled fresh JSON, and saved the user's original to a .sqlcmd-backup file. dlevy flagged that this clobbers the backup on every subsequent run (e.g. creating a second container loses the first backup) and silently destroys hand-authored comments.
PR #688 follow-up commit replaced the strip-and-marshal round trip with github.com/tailscale/hujson. We now parse the original AST and apply an RFC 6902 patch that touches only the two keys we own (mssql.connections, mssql.connectionGroups). Comments, trailing commas, and unrelated user keys round-trip untouched on replace operations, and the .sqlcmd-backup file is no longer needed.
Remaining limitation
hujson's Patch "add" operation (used when the document doesn't yet have an mssql.connections key) can blank a comment immediately adjacent to the insertion point. Unrelated keys are preserved; only a comment line at the insertion site is affected. This is a one-time event per settings.json (subsequent runs use the "replace" path, which fully preserves comments).
Additionally, createProfile / updateOrAddProfile in cmd/modern/root/open/vscode.go operate on map[string]interface{} for the connection array itself. This means per-connection comments inside mssql.connections[*] are not preserved when sqlcmd updates an existing profile.
Proposed work
Refactor cmd/modern/root/open/jsonc.go and the profile-construction helpers to operate directly on hujson.Value AST nodes instead of decoded maps. Specifically:
- Walk the parsed root
*hujson.Objectto findmssql.connectionsandmssql.connectionGroupsmembers, mutating theirValuein place rather than going through a JSON patch. - For the array of profiles, locate the existing profile member by
idand rewrite its*hujson.Objectfields one at a time, leaving member ordering and surrounding extras intact. - When inserting a new profile or a new top-level key, set
ObjectMember.Name.BeforeExtraexplicitly so the preceding comment isn't absorbed by hujson's leading-comment extraction.
Verification
The round-trip test in cmd/modern/root/open/jsonc_test.go (TestApplyJSONCSettingsUpdates_PreservesComments) should be extended to cover the add-comment-adjacent case, and a new test should verify per-connection comments inside the mssql.connections array survive an update to an existing profile.
References
- PR: #688
- Related review thread: https://github.com/microsoft/go-sqlcmd/pull/688#discussion_r3325235606
- hujson patch semantics: https://github.com/tailscale/hujson/blob/main/patch.go
- Lingua principale
- Go
- Stelle
- 595
- Fork
- 91
- Merge medio
- 9h 35m
- PR unite (30g)
- 1
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. Parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/go-sqlcmd
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Fix CVEs in Version v1.10.0Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
microsoft/go-sqlcmd#733 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
":Help" command not workingAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/go-sqlcmd
Issue simili
-
bug needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug P2 reliability
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
afreidah/s3-orchestrator#1564 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
blinklabs-io/gouroboros#2577 ·
I maintainer di solito rispondono entro 1 giorno
-
agentic-workflows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno