Skip to content

Fix #766: handle missing terms-of-use columns gracefully#1095

Open
bleedblack1 wants to merge 4 commits intomalariagen:masterfrom
bleedblack1:fix/766-lookup-terms-of-use-missing-columns
Open

Fix #766: handle missing terms-of-use columns gracefully#1095
bleedblack1 wants to merge 4 commits intomalariagen:masterfrom
bleedblack1:fix/766-lookup-terms-of-use-missing-columns

Conversation

@bleedblack1
Copy link
Contributor

@bleedblack1 bleedblack1 commented Mar 10, 2026

Summary

Fixes #766

When terms_of_use_expiry_date or terms_of_use_url columns are missing
from the manifest (e.g. during pre-release), functions like
lookup_terms_of_use_info() and _sample_set_has_unrestricted_use()
previously raised a cryptic KeyError. They now raise a clear,
descriptive ValueError with a helpful message.

Changes

  • malariagen_data/anoph/base.py:

    • lookup_terms_of_use_info(): gracefully handles missing
      terms-of-use columns, raises descriptive ValueError
    • _sample_set_has_unrestricted_use(): raises descriptive
      ValueError when unrestricted_use column is missing
    • Fixed cache logic indentation bug in lookup_terms_of_use_info()
  • tests/anoph/test_base.py:

    • test_lookup_terms_of_use_info_missing_columns: verifies correct
      error when columns are missing
    • test_sample_set_has_unrestricted_use_missing_column: verifies
      correct error for missing unrestricted_use column
    • test_sample_sets_no_terms_of_use: verifies sample_sets()
      still works when terms-of-use columns are absent

Test Results

  • 34/34 tests passing locally (Python 3.11)
  • Coverage passing
  • Linting passing

When sample sets don't have terms-of-use columns (terms_of_use_expiry_date,
terms_of_use_url, unrestricted_use) in the manifest, the functions now
raise descriptive ValueError messages instead of KeyError.

Changes:
- lookup_terms_of_use_info: Check for column existence before accessing
- _sample_set_has_unrestricted_use: Validate unrestricted_use column exists
- Both functions now provide clear error messages explaining missing data

Fixes malariagen#766
@bleedblack1
Copy link
Contributor Author

bleedblack1 commented Mar 10, 2026

All 34 tests pass locally on Python 3.11, including on the master branch.
The tests (3.12, >=2.0.2,<2.1) CI failure appears to be a pre-existing
infrastructure issue unrelated to this PR.

  • Coverage passing
  • Linting passing
  • 34/34 tests passing locally

Ready for review! @jonbrenas @tristanpwdennis

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.

sample_metadata and lookup_terms_of_use_info does not work when there is no terms-of-use info

1 participant