Skip to content

Drop the generated addon data and the stale gr.json regime - #976

Open
samlown wants to merge 1 commit into
mainfrom
drop-generated-addon-data
Open

samlown wants to merge 1 commit into
mainfrom
drop-generated-addon-data

Conversation

@samlown

@samlown samlown commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Removes data/addons and its generator, plus the orphaned data/regimes/gr.json.

Nothing reads the addon data

No code in GOBL loads it. The only runtime reads of the embedded FS are schemas/, catalogues/ and currency/ — the addon files are write-only artifacts. Outside core:

  • gobl.org publishes only data/schemas → static/draft-0; the addon files were never public assets.
  • gobl.docs already builds its addon pages from tax.AllAddonDefs() plus a bundle import, explicitly because addons left core.
  • gobl.ts reads the gobl.dev API.
  • gobl.dev was the last consumer, and invopop/gobl.dev#58 moves it to the registry.

They cannot be correct any more

The generator writes one file per addon compiled into core. As addons moved to their own modules the directory became a shrinking subset that still looked authoritative: 13 files for the 25 addon keys GOBL recognises (13 built in, 12 on the approved external list).

That is not a theoretical problem — it is what gobl.dev hit. GET /v0/addons/mx-cfdi-v4 returned 404 for every externally implemented addon while /v0/addons advertised all 25, because the handler read this directory.

And the generator never prunes

data/addons/pl-favat-v2.json shipped for an addon deleted from the code — 0.505 registers only V3 — and was served as a live definition for a key that would fail validation in $addons.

data/regimes/gr.json is the same failure in the other generated directory: Greece registers under EL, so gr.json is a leftover from before that rename. It is unreachable from the registry, was last regenerated in 2024-07 while el.json kept moving, and /v0/regimes/GR still serves it today — 16KB of two-year-old data in an older schema shape (carries extensions/tags/payment_means_keys, missing alt_country_codes/tax_scheme/sources) against 6KB for the real EL. go generate does not recreate it.

The replacement

The registry is the source of truth and renders the same bytes on demand:

obj, _ := schema.NewObject(tax.AddonForKey(key))
data, _ := json.MarshalIndent(obj, "", "  ")

That is exactly what addons/generate.go did, so output is unchanged — verified byte-for-byte against all 13 files before deleting them. Unlike the files, it covers every addon the binary has loaded.

Checks

mage check passes: lint, generate, tests, no uncommitted changes. go generate . recreates neither data/addons nor gr.json.

Breaking change

data is an exported package in a published module, so an external consumer could be doing data.Content.ReadFile("addons/…"). Such a consumer is already getting a partial answer, but it is a real break — hence the breaking marker in the change note, and worth a minor release rather than a patch.

🤖 Generated with Claude Code

The JSON definitions under data/addons were generated but never read: no
code in GOBL loads them, and the only runtime reads of the embedded FS
are schemas, catalogues and currency.

They also cannot be correct any more. The generator writes one file per
addon compiled into core, so as addons moved to their own modules the
directory became a shrinking subset that still looked authoritative — 13
files for the 25 addon keys GOBL recognises. A consumer reading it gets a
silently partial answer; gobl.dev served 404s for every externally
implemented addon until it switched to the registry.

Nor does the generator prune. data/addons/pl-favat-v2.json shipped in
0.507's predecessors for an addon deleted from the code, and was served
as a live definition for a key that would fail validation in $addons.

Remove the directory, the generator, and its go:generate directive, and
drop addons from the embed set. The registry is the source of truth and
renders the same bytes on demand:

    schema.NewObject(tax.AddonForKey(key))

marshalled with a two-space indent, which is exactly what the generator
did. gobl.docs already works this way.

data/regimes/gr.json goes too, for the same reason in the other generated
directory: Greece registers under EL, so gr.json is a leftover from
before that rename. It is unreachable from the registry, was last
regenerated in 2024 while el.json kept moving, and go generate does not
recreate it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.88%. Comparing base (765f238) to head (d249fb2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #976   +/-   ##
=======================================
  Coverage   96.88%   96.88%           
=======================================
  Files         335      335           
  Lines       15916    15916           
=======================================
  Hits        15421    15421           
  Misses        494      494           
  Partials        1        1           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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