Skip to content

Ignore unrecognised codelist xml in gen.py (version-1.05) - #509

Merged
robredpath merged 3 commits into
version-1.05from
version-1.05-fix-gen-extra-elements
Aug 4, 2026
Merged

Ignore unrecognised codelist xml in gen.py (version-1.05)#509
robredpath merged 3 commits into
version-1.05from
version-1.05-fix-gen-extra-elements

Conversation

@robredpath

Copy link
Copy Markdown
Contributor

Replicates #505 for version-1.05.

IATI/IATI-Codelists-NonEmbedded#427 added namespaced extras elements (crs, tossd), which crash gen.py's csv writer. As @Bjwebb noted on #505, this needs doing for each version of the standard that we build.

The two gen.py commits are cherry-picked cleanly from #505. The gen.sh commit was applied by hand, because gen.sh on this branch has a different structure to 2.x — it converts the non-embedded xml with v3tov2.py on the way in and has an extra v2tov3.py step, so there are five python steps to guard rather than four.

Verified on this branch

Ran ./gen.sh with IATI-Codelists-NonEmbedded at master:

  • exits 0, no tracebacks
  • codelists.json and codelists.xml present (both were missing from the last IATI-Reference-Generator release)
  • no namespaced keys in the json output
  • FinanceType.csv back to 88 rows / 6 columns
  • extras:crs/extras:tossd still present in the xml output

Bjwebb and others added 3 commits August 4, 2026 15:56
extrasaction='ignore' applies only to the csv writer, so the namespaced
`extras` elements added in IATI-Codelists-NonEmbedded#427 still reached
the json output as fully-qualified keys, e.g.
"{https://namespaces.iatistandard.org/codelist_extras}crs".

Filtering in codelist_item_todict covers both writers, so the csv and
json output agree. The elements remain in the xml output, consistent with
activation-date and withdrawal-date, which are also xml-only.

extrasaction='ignore' is kept, so unexpected non-namespaced elements
cannot break the csv writer either.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
gen.sh had no error handling around its python steps and no `set -e`, so
it returned the exit status of its last command. When gen.py crashed the
script still exited 0, and callers' `./gen.sh || exit 1` guards never
tripped. CI's "Build and test" step passed, and IATI-Reference-Generator
produced a release with codelists.json and codelists.xml missing and
truncated csv output.

Guarding the python steps makes that failure visible.

The git, cp and rm steps are left unguarded rather than using
`set -o errexit`, to avoid changing behaviour around the optional
IATI-Codelists-NonEmbedded pull.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@robredpath

Copy link
Copy Markdown
Contributor Author

1.05 is deprecated

@robredpath robredpath closed this Aug 4, 2026
@robredpath robredpath reopened this Aug 4, 2026
@robredpath
robredpath requested a review from Bjwebb August 4, 2026 15:20
@Bjwebb

Bjwebb commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

We've realised that the dashboard will break without this fix, so we've re-opened the PR.

@Bjwebb Bjwebb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this branch with the dashboard unit tests, and it now works.

@robredpath
robredpath merged commit ab2501d into version-1.05 Aug 4, 2026
@robredpath
robredpath deleted the version-1.05-fix-gen-extra-elements branch August 4, 2026 15:29
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