Skip to content

fix: validate Python callable file and name together - #849

Open
cen-zp wants to merge 2 commits into
astronomer:mainfrom
cen-zp:fix/101-python-callable-pair-validation
Open

fix: validate Python callable file and name together#849
cen-zp wants to merge 2 commits into
astronomer:mainfrom
cen-zp:fix/101-python-callable-pair-validation

Conversation

@cen-zp

@cen-zp cen-zp commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • validate that python_callable_name and python_callable_file are provided together
  • raise a clear DagFactoryException for either incomplete configuration
  • cover both missing-pair cases and tighten the existing exception assertion

Root cause

The builder only rejected configurations where all Python callable options were absent. When exactly one file-based callable parameter was provided, it accessed the missing dictionary key directly and raised KeyError.

Validation

  • hatch run tests.py3.11-3.2:test — 295 passed, 7 skipped, 1 deselected
  • pytest tests/test_dagbuilder.py -q — 87 passed, 4 skipped
  • applicable pre-commit checks on the changed files

Fixes #101

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.67%. Comparing base (3c29d9e) to head (9dc5ab2).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #849   +/-   ##
=======================================
  Coverage   95.66%   95.67%           
=======================================
  Files          13       13           
  Lines        1385     1387    +2     
=======================================
+ Hits         1325     1327    +2     
  Misses         60       60           

☔ 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.

@tatiana tatiana left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@cen-zp Thanks for the fix, and nice call not just flipping the and to or as the issue suggested - that would have broken the valid "python_callable only" and "name + file" configs. Doing an XOR check to the python_callable-absent case feels like the right approach,

One optional cleanup: the new check repeats not task_params.get("python_callable") right before the existing if not ...:, so it reads as three back-to-back python_callable checks.

I'm happy to approve and merge it once you change it out of draft!

@tatiana tatiana self-assigned this Jul 28, 2026
@cen-zp
cen-zp force-pushed the fix/101-python-callable-pair-validation branch from 9dc5ab2 to 67440bc Compare July 28, 2026 11:39
@cen-zp
cen-zp marked this pull request as ready for review July 28, 2026 11:42
@cen-zp
cen-zp requested review from a team and gyli as code owners July 28, 2026 11:42
@cen-zp
cen-zp requested review from pankajastro and pankajkoti and removed request for a team July 28, 2026 11:42
@cen-zp

cen-zp commented Aug 2, 2026

Copy link
Copy Markdown
Author

Hi @tatiana, thanks again for the review! I’ve applied the optional cleanup and marked the PR ready for review. The latest workflow runs also appear to be awaiting maintainer approval. Could you please take another look when you have a chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Looks like a bug in dagbuilder.py

4 participants