Skip to content

fix: read GAM's CSV with its backslash escape character - #67

Merged
goetchstone merged 1 commit into
mainfrom
fix/gam-csv-escape-char
Oct 30, 2026
Merged

goetchstone merged 1 commit into
mainfrom
fix/gam-csv-escape-char

Conversation

@goetchstone

Copy link
Copy Markdown
Owner

What and why

GAM writes every CSV with a backslash escape character (its setDialect); the parser read without one, so a formatjson row whose JSON held a quote was dropped silently and backslashes came back doubled. Found by SwiftGamGui; item A1 of the new backport plan (Phase A approved). History: failure log.

  • core/gam/parser.py: read with escapechar="\\"; argv unchanged.
  • Mock: print users prints GAM's escaped primaryEmail,JSON CSV (was NDJSON); carol's record needs the escapes.
  • scripts/gam_rc_table.py: under the build's Python, refuses a build whose CSV dialect moved and emits samples; tests/test_gam_csv_dialect.py reads them back and holds the mock's bytes to GAM's writer.
  • Property tests write GAM output with the escape; golden test pins 7.49.02's bytes.

How it was verified

  • .venv/bin/python -m pytest -q passes
  • make lint is clean (ruff + mypy)
  • A screen changed: make a11y passes and docs/guide.md says what's new — n/a

1609 passed offline; the real-reference mode (GAM_RC_TABLE from python3.15, EXIT_CODES_REQUIRE_GAM=1) passes too. Without the parser fix, 8 tests fail.

If it builds or runs a gam command

  • The argv is built in GAMCommands as a list; each operator-supplied value is exactly one element (unchanged)
  • A write goes ChangePreview → guard.enforce() in the apply route → _run_write — no write touched
  • Checked against the vendored grammar; a mock change fails the way real GAM fails
  • Live status stated below

Live status: Offline only, checked against bytes the vendored 7.49.02 build writes. A read-only check of a user whose title holds a quote is still owed.

Nothing private

  • No credentials, real domain names, real addresses, or captures from a real tenant

🤖 Generated with Claude Code

- GAM's setDialect escapes with a backslash; the parser had none, so a formatjson
  row whose JSON held a quote was dropped and backslashes came back doubled.
- The mock's print users now prints GAM's escaped CSV; the property tests write
  GAM output with the escape.
- scripts/gam_rc_table.py refuses a build whose CSV dialect moved and emits
  samples the suite reads back.
- Adds the SwiftGamGui backport plan (Phase A approved; this is A1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@goetchstone
goetchstone merged commit add6308 into main Oct 30, 2026
17 checks passed
@goetchstone
goetchstone deleted the fix/gam-csv-escape-char branch October 30, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant