Skip to content

Fix filter_* FK violation and add flux/filter consistency check - #149

Merged
monodera merged 2 commits into
mainfrom
tickets/OBSPROC-143
Aug 4, 2026
Merged

Fix filter_* FK violation and add flux/filter consistency check#149
monodera merged 2 commits into
mainfrom
tickets/OBSPROC-143

Conversation

@monodera

@monodera monodera commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add_backref_values now normalizes filter_* columns (NaN or empty string → None) for every insert path (fluxstd, sky, user_pointing, and target without --from-uploader), not just the uploader-specific target path. This was causing Key (filter_g/i)=(NaN) is not present in table "filter_name" errors when a bare NaN got serialized to the literal string "NaN" by the database driver.
  • Also extended the normalized band list to include u/v, which the old uploader-only code was missing.
  • Added check_filter_flux_consistency, which raises a ValueError if a row has a flux (or flux error) value for a band whose filter is missing — a flux measurement without a known filter is not physically meaningful.

Test plan

  • uv run pytest tests --ignore=tests/integration
  • Verified against the originally reported input file (target_bc3a0193fa593b7c.ecsv): filter_g/filter_i NaNs now normalize to None with no leftover NaN floats, and the file passes the new consistency check without false positives.

🤖 Generated with Claude Code

monodera and others added 2 commits August 4, 2026 14:33
… consistency check

Missing filter_* values (NaN from masked ecsv columns, or empty strings
from CSV columns read with keep_default_na=False) were only normalized
to None in the uploader-specific target code path. Any other insert
path (fluxstd, sky, user_pointing, and target without --from-uploader)
went through add_backref_values, which had no such normalization, so a
bare NaN was sent to the database and coerced to the literal string
"NaN", violating the filter_name foreign key constraint.

Centralize the normalization in add_backref_values so it covers every
insert path, and add check_filter_flux_consistency to reject rows
where a flux value is present but its filter is missing, since that
combination is not physically meaningful.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@monodera
monodera merged commit 38e0953 into main Aug 4, 2026
@monodera
monodera deleted the tickets/OBSPROC-143 branch August 4, 2026 05:51
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