A CSV importer can finish without errors and still put an account identifier where a usage quantity belongs. GitHub’s December 2 report update creates exactly the kind of schema change that exposes that mistake: reports with a username column now have a user_id column beside it. Every later column moves one position to the right.
If your importer reads “column seven” rather than the field’s header, a successful run tells you very little. A numeric identifier can pass a numeric conversion. The output file can look tidy. The wrong value has simply travelled farther into the application.
GitHub explicitly recommends reading these reports by header name. That is the immediate fix. The accompanying identity change also makes it worth checking what the importer does when a field exists but its value is empty.
Make the file describe its fields
An importer should identify the report type it supports, read the header, and verify its required fields before processing records. Added fields can be compatible with that contract. Missing required fields should produce a clear schema error, rather than quietly becoming zero or an empty string.
Python’s CSV library provides a useful starting point. This illustrative loader checks the identity columns of a supported report; it is not a complete GitHub billing importer:
import csv
def read_identity_rows(stream):
reader = csv.DictReader(stream)
headers = reader.fieldnames or []
if len(headers) != len(set(headers)):
raise ValueError("Duplicate CSV headers")
if not {"username", "user_id"}.issubset(headers):
raise ValueError("Unsupported report: identity columns missing")
return list(reader)
Reading by name makes column order irrelevant to the lookup. Checking for duplicate headers avoids accepting an ambiguous mapping. A production importer also needs its own rules for malformed rows, required usage fields, number formats, and the report types it accepts. The small example deliberately stops before those decisions.
Keep the input file and validation result attached to the import attempt. That gives a maintainer something concrete to inspect when an upstream export changes again. An “import failed” message without the expected and observed headers sends the investigation back to guesswork.
An empty identity is not a missing column
The new column is not a promise that every row identifies a person. GitHub says it includes bot accounts and is empty for usage that is not associated with an account. Deleted accounts retain an ID even when their username is empty. The summarized report is unchanged.
Those cases need different handling. A summarized report without identity columns should not accidentally enter a loader written for per-account records. A supported report with an empty identity value needs an explicit path for unattributed usage. A deleted account with an ID should not disappear merely because the display name is blank.
GitHub’s report reference describes user_id as stable across username changes and explains how to match it to audit-log identity fields. Use the username for a readable label; retain the identifier for relationships. Do not turn every empty username into the same account.
That last shortcut can corrupt a report even after the column-order bug has been fixed. Several distinct deleted accounts can share the same empty display value. Grouping on that value throws away the distinction the new field supplies.
Keep the source identity when records move
In The Garden’s platform, I built shared types, validation, and domain rules for member and staff tools. People and households connect to giving, check-in, scheduling, communications, and staff work. The Planning Center replacement remains staged, with migration and acceptance work still in progress.
That is a practical reason to care about import contracts. A person’s name is useful to the operator looking at a row. It is a poor substitute for an explicit relationship between a source record and the destination record it updates.
For a comparable migration, I would keep the source-system name and source identifier beside the destination identifier. That mapping is a proposed implementation pattern, not a claim about a particular Garden migration table. It lets a later import find the same destination after a display-name change. It also gives an operator a place to investigate unresolved matches before combining records.
Header-based parsing protects the meaning of each incoming field. Identity mapping protects the relationship that field represents. Neither check establishes that two records should be merged; that remains a separate domain decision.
Before enabling the revised importer, run a small fixture set: reorder the columns, add an unrelated column, remove a required header, and include a row with an empty username but a populated ID. Include an accountless row as well. The reordered file should preserve every field value; the missing-header file should fail before processing. In the retained output, the deleted account and the accountless row should still be distinguishable.
Top comments (1)
Keith, the part that stays with me is that the failure is silent twice over: the import finishes, the numbers convert, and the tidy output just carries the wrong value further in. Header-name reading fixes the shift, but your loader leaves one trap open that your own fixture list hints at: a renamed account shows up as two rows with different usernames and the same user_id. Your check validates that both columns exist, but nothing in read_identity_rows stops a downstream group-by-username from counting that person twice. Would you add a fixture row for it — same user_id, two usernames — and assert the import collapses them to one identity? Second, smaller one: the duplicate-header check catches exact duplicates, but a BOM on the first header or a casing variant would make the subset check fail with 'Unsupported report' on a file GitHub actually sent. Do you normalize headers before that check, or is that a failure you would rather have loud?