The two selected indexes point to ID and repository after insertion.
The same weekly GitHub usage CSV can still open, yet a script that reads the repository and amount by position can start returning an account ID and a repository instead. With permissive conversion, you might not see the misread until aggregation or reporting.
Takeaway: select fields by header, preserve IDs as text, and keep rows with no associated ID. Reject duplicate or missing required headers and malformed row widths before committing a rollup.
01 · What changes on December 1?
GitHub says its username-bearing detailed, AI, and premium request usage reports will insert user_id immediately after username starting December 1, 2026. This covers GitHub Enterprise Cloud and standalone GitHub Team organizations. The summarized report stays unchanged. GitHub changelog
The announcement also covers affected REST exports, not every billing API response. The documented /usage endpoint returns summarized data, for example. Identify the report your job actually consumes. This schema change is separate from the December 30 Copilot code review payer change. GitHub billing reports reference
02 · Same indexes, different fields
We ran Python 3.12 against two synthetic CSV layouts. Their first data row represents the same repository and amount; the second layout adds one column to the right of username. Indexes below are zero-based.
| Read method | Old first row | New first row |
|---|---|---|
| Indexes 1 and 2 |
example/demo, 1.25
|
00123456, example/demo
|
| Repository and amount by header |
example/demo, 1.25
|
example/demo, 1.25
|
Header lookup survives the insertion. A bare DictReader can still overwrite duplicate keys, so we validate the header and row shape explicitly.
Keep valid rows with missing identity and reject malformed input.
03 · Reproduce it
Save as usage_lab.py and run python3 usage_lab.py. No packages or GitHub token are required. The amounts are test values, not observed prices or charges.
import csv
import io
from decimal import Decimal, InvalidOperation
OLD = "username,repository,net_amount\nalex,example/demo,1.25\n"
NEW = (
"username,user_id,repository,net_amount\n"
"alex,00123456,example/demo,1.25\n"
",,example/demo,0.75\n"
",0077,example/demo,0.50\n"
)
REQUIRED = {"username", "repository", "net_amount"}
def by_name(source):
reader = csv.DictReader(io.StringIO(source, newline=""), strict=True)
fields = reader.fieldnames or []
if len(set(fields)) != len(fields):
raise ValueError("duplicate header")
if not REQUIRED.issubset(fields):
raise ValueError("missing required header")
for row in reader:
if None in row or any(value is None for value in row.values()):
raise ValueError("wrong row width")
if not row["repository"]:
raise ValueError("missing repository")
try:
amount = Decimal(row["net_amount"])
except InvalidOperation as exc:
raise ValueError("invalid amount") from exc
if not amount.is_finite():
raise ValueError("non-finite amount")
yield row["repository"], amount, row.get("user_id") or None
if __name__ == "__main__":
for label, sample in (("old", OLD), ("new", NEW)):
first = list(csv.reader(io.StringIO(sample)))[1]
print(label, "fixed:", first[1:3])
for repo, amount, user in by_name(sample):
print(label, "named:", repo, amount, user)
We ran the script twice and obtained identical output:
old fixed: ['example/demo', '1.25']
old named: example/demo 1.25 None
new fixed: ['00123456', 'example/demo']
new named: example/demo 1.25 00123456
new named: example/demo 0.75 None
new named: example/demo 0.50 0077
Six unit tests covered position drift, both layouts and blank IDs, a quoted comma, duplicate or missing required headers, short and long rows, and invalid or non-finite amounts and a blank repository. None represents missing identity in this sample, not a reason to discard the row. A row with no username but with ID 0077 retains the leading zeros.
04 · Decide what your pipeline should accept
- Check the export type and how you obtain it. A pipeline reading only the summarized report doesn't need a change for this column insertion.
- Test both header versions and explicitly list the keys your aggregation needs. This sample enforces repository presence for a repository-only rollup. A pipeline that includes usage without a repository needs a different contract.
- For the first run, match the date, product and currency scope and reconcile row counts and amounts. Fail the batch or quarantine the file on invalid input instead of finalizing a partial rollup.
The test did not use a real GitHub export or verify billing. GitHub says usage from deleted accounts can appear on separate rows, so per-row rounding can move the last decimals even when the pricing calculation hasn't changed. Don't assume identical totals prove the parser is right, or that a small difference necessarily proves it is wrong. GitHub changelog
Disclosure: AI generated this article and its diagrams. The Python verification used synthetic CSV fixtures offline, not real usage records.


Top comments (0)