Skip to content

fix(mask): read env files, with two columns and no guesses (#13) - #14

Merged
imgul merged 1 commit into
mainfrom
arena/85cab603-env-compare
Oct 20, 2026
Merged

imgul merged 1 commit into
mainfrom
arena/85cab603-env-compare

Conversation

@imgul

@imgul imgul commented Oct 20, 2026

Copy link
Copy Markdown
Member

Closes #13.

The masking page was built on a CSV reader, which is the wrong model for a .env file. With no header and no delimiter to find, the guesswork turned a banner comment into a column title, invented Column 2…N from the padding, and listed comments as rows — and for a file without comments it consumed the first variable as the header, printing its value as a column name, unmasked, and dropping it from the export. A masking tool that publishes a value is not a formatting bug.

What the page reads now

  • One row per KEY=value assignment, in file order — the first line included.
  • Comment, blank and unreadable lines are not rows. They are counted and reported: "4 comment lines, 1 blank line skipped".
  • Duplicate keys resolve the way dotenv resolves them (last one wins), and the repeated keys are named.
  • A multi-column CSV is refused with "this page handles env files", not parsed into a guessed table.
  • Exactly two columns: key and value. No delimiter detection, no headers, no generated column names.

The reported file now yields what the issue asked for:

BETTER_AUTH_SECRET=
GOOGLE_GENERATIVE_AI_API_KEY=
DATABASE_URL=********
LOG_LEVEL=info

with {"comments": 5, "blank": 1, "unreadable": 0} in the summary — no value in a label anywhere.

Deleted, not parked

src/core/csv and its 15 tests are gone with the feature that used them. A second input format is a product decision, and the issue asked for one shape.

Output

.env-shaped: one KEY=masked-value per line, no comments, no originals, downloaded as <name>.masked.env. It reuses the compare engine's grammar, so the two pages cannot disagree about export, quoting or trailing comments. formatValue single-quotes anything containing #, " or a backslash — the only form dotenv returns verbatim — and only newlines force double quotes; a test round-trips its own output back through the parser.

Defaults keep the masked file useful: obvious configuration (info, 3000, production, a credential-free URL) stays visible, credential-shaped values hide, and a key whose name says secret outranks a harmless-looking value. Warnings now name keys — "DATABASE_URL, OPENAI_API_KEY are still visible" — rather than a column index.

Rename

Nav entry, page title, buttons, file picker label, README, PRD §8.6 / US-24 and the tests all say env. The route stays /mask, which describes the action and needs no redirect.

Verification

  • npm run check — 459 tests / 25 files, tsc clean, build ✓, privacy guard ✓
  • New tests/unit/env-source.test.ts (12) and a rewritten tests/unit/mask.test.ts (18): banner, first line, comments, blanks, duplicates, quoting round-trips, wide-CSV refusal
  • 19 component tests assert the two-column shape and the actual regressions: no value in a heading or summary line, no comment as a row, the first line as a row
  • e2e/mask.spec.ts checks the same shape against real layout, with the no-request and no-storage promises unchanged

Closes #13.

The masking page was built on a CSV reader, which is the wrong model for a
.env file. With no header and no delimiter to find, the guesswork turned a
banner comment into a column title, invented Column 2…N from the padding and
listed comments as rows — and for a file without comments it consumed the
first variable as the header, printing its value as a column name, unmasked,
and dropping it from the export. A masking tool that publishes a value is not
a formatting bug.

The page now reads the format it is named for:

- one row per KEY=value assignment, in file order, first line included;
- comment, blank and unreadable lines are not rows, and are counted and
  reported ("4 comment lines, 1 blank line skipped");
- duplicate keys resolve the way dotenv resolves them, last one wins, and the
  repeated keys are named;
- a multi-column CSV is refused with a message instead of parsed into a table.

src/core/csv and its 15 tests are deleted with the feature that used them: a
second input format is a product decision, and the issue asked for one shape.

Output is .env-shaped — KEY=masked-value per line, no comments, no values,
<name>.masked.env — and reuses the compare engine's grammar, so the two pages
cannot disagree about export, quoting or trailing comments. formatValue
single-quotes anything containing #, " or a backslash because single quotes
are the only form dotenv returns verbatim, and only newlines force double
quotes; a test round-trips its own output through the reader.

Defaults keep the masked file useful: obvious configuration (info, 3000,
production, a credential-free URL) stays visible, credential-shaped values
hide, and a key whose name says secret outranks a harmless-looking value.
Warnings now name keys — "DATABASE_URL, OPENAI_API_KEY are still visible" —
rather than a column index.

Renamed throughout: nav entry, page title, buttons, file picker, README,
PRD §8.6 / US-24 and the tests. The route stays /mask, which describes the
action and needs no redirect.

Tests: 459 (25 files). Two new suites replace the CSV one,
tests/unit/env-source.test.ts (12) and a rewritten tests/unit/mask.test.ts
(18); the 19 component tests assert the two-column shape and the actual
regressions (no value in a heading or summary, no comment as a row, first
line as a row), and e2e/mask.spec.ts checks the same shape with the
no-request and no-storage promises unchanged.
@imgul
imgul merged commit 774686c into main Oct 20, 2026
1 check failed
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.

mask: .env files are parsed as CSV — comments become rows, columns are guessed, and it should be “Mask env” with two columns

1 participant