Skip to content

fix(export): prefix CSV data keys that collide with id/timestamp/duration - #795

Merged
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/csv-export-reserved-column-collision
Oct 10, 2026
Merged

ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/csv-export-reserved-column-collision

Conversation

@TimeToBuildBob

@TimeToBuildBob TimeToBuildBob commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

The bucket CSV export (#722) writes id,timestamp,duration followed by the union of event data keys. A data key named id, timestamp or duration produced a duplicate header name, so the columns were unambiguous by position but not by name. Greptile flagged this on ActivityWatch/aw-server#178.

Fix: a data key that would repeat an earlier header name gets a data. prefix, repeated until unique (duration → data.duration; data keys arrive sorted, so a literal data.id key keeps data.id and the id key becomes data.data.id). Only the header changes; values are still read by the original key. Keys that don't collide are unchanged, and the >32-key single data JSON column is unaffected.

A matching aw-server (Python) PR follows so both servers emit the same header.

Tests: new csv_header_prefixes_data_keys_that_collide_with_columns (header) and streamed_csv_prefixed_columns_carry_original_key_values (full export, header↔row); cargo test -p aw-datastore --lib export 16 passed, the aw-server CSV API test passes, fmt and clippy clean.

…tion

A data key named id, timestamp or duration produced a duplicate header
name. Prefix such keys with "data." (repeated until unique) so every
column name is distinct; values are still read by the original key.

Git-Session-Id: 838c
@greptile-apps

greptile-apps Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how CSV export columns are named.

The PR appears safe to merge, with no outstanding findings.

Summary

The PR gives colliding CSV data headers a repeated data. prefix while keeping value lookup tied to the original keys.

  • The change since the last review adds a full-export test that checks reserved fields and all four colliding data keys.
  • This addresses the previous request to test that renamed columns contain the right values.
  • No new actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "test(export): check prefixed CSV columns..."

Comment thread aw-datastore/src/export.rs
Git-Session-Id: 76980a96-158b-5a96-a469-b2279ea3a5ba
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@codecov

codecov Bot commented Oct 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.96%. Comparing base (656f3c9) to head (292b112).
⚠️ Report is 185 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #795       +/-   ##
===========================================
+ Coverage   70.81%   83.96%   +13.14%     
===========================================
  Files          51       82       +31     
  Lines        2916    10806     +7890     
===========================================
+ Hits         2065     9073     +7008     
- Misses        851     1733      +882     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@TimeToBuildBob

TimeToBuildBob commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 AI code review

Adds csv_header_names(), which renames data keys that collide with the fixed id/timestamp/duration columns by prepending data. until the name is unique, and routes write_csv_header through it while value rows still read by the original key. Adds two tests covering the rename logic and header-to-row alignment for prefixed columns in a streamed export.

Safe to merge — no P0/P1 findings

Confidence 5/5

✅ No thread-worthy findings. Advisory notes follow; they are retained without opening review threads.

1 advisory finding (summary-only, not scored)

These P2 guard, heuristic, trade-off, or documentation claims are retained for judgment without opening review threads.

⚠️ P2 medium — aw-datastore/src/export.rs

This is a fix(...) PR but no test files are included in the diff. Erik's feedback: 'where is the repro & fixes they are supposed to catch' (gptme#3441), 'that measurement should come with a regression test' (gptme#3446). Add a test that would have caught this bug. (Advisory: Erik merged all such PRs but consistently requested tests.)

Add a test file that reproduces the bug before the fix and passes after it.

How this was verified: static preflight: fix-commit + touched-files scan (rule 7)

Files changed (1) — the diff as I read it
  • aw-datastore/src/export.rs — Adds csv_header_names() that prefixes colliding data keys with data.; writes headers through it; adds two tests for prefixing and value alignment.

Reviewed 292b1124a9d1 · openrouter/deepseek/deepseek-v4-flash-0731 · llm engine · 901s · about this reviewer

Maintainer commands

@TimeToBuildBob review (own line) — fresh review · @TimeToBuildBob fix — a worker acts on the findings. Once per comment; 👀 = received.

@ErikBjare
ErikBjare merged commit 344f476 into ActivityWatch:master Oct 10, 2026
8 checks passed
TimeToBuildBob added a commit to TimeToBuildBob/aw-server that referenced this pull request Oct 10, 2026
…tion

A data key named id, timestamp or duration produced a duplicate header
name. Prefix such keys with "data." (repeated until unique), matching
ActivityWatch/aw-server-rust#795. Values are still read by the original key.

Git-Session-Id: 838c
TimeToBuildBob added a commit to TimeToBuildBob/aw-server that referenced this pull request Oct 14, 2026
…tion

A data key named id, timestamp or duration produced a duplicate header
name. Prefix such keys with "data." (repeated until unique), matching
ActivityWatch/aw-server-rust#795. Values are still read by the original key.

Git-Session-Id: 838c
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.

2 participants