Skip to content

Add prek hook to catch operators missing from common-ai docs index - #71783

Merged
potiuk merged 2 commits into
apache:mainfrom
ColtenOuO:common-ai-operators-index-test
Aug 25, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
ColtenOuO:common-ai-operators-index-test

Conversation

@ColtenOuO

@ColtenOuO ColtenOuO commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Sumarry

Adds a regression test guarding providers/common/ai/docs/operators/index.rst's "Choosing the right operator" table, which is hand-maintained and has already silently gone stale once (LLMSchemaCompareOperator was missing from it until #71738).

The test walks every class defined directly in providers/common/ai/src/airflow/providers/common/ai/operators/ and
flags the ones that are:

  • a subclass of airflow.sdk.BaseOperator (transitively, so operators that inherit from another local operator like LLMOperator still count)
  • actually defined in that module, not merely imported into it — so classes like BaseOperator itself, pydantic BaseModel helpers (SchemaMismatch, SchemaCompareResult), BaseOperatorLink subclasses (HITLReviewLink), and imported mixins (LLMApprovalMixin, BranchMixIn) are correctly excluded and never flagged.

Each remaining class name is checked against the text of docs/operators/index.rst. Nothing else in CI catches this class of gap today.

Changes

  • Adds scripts/ci/prek/check_common_ai_operators_index.py and registers it as
    the check-common-ai-operators-index hook in providers/.pre-commit-config.yaml.
  • Replaces the unit test from the first revision of this PR, per review feedback.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Sonnet 5)

The "Choosing the right operator" table in
providers/common/ai/docs/operators/index.rst is hand-maintained and has
already gone stale more than once (LLMSchemaCompareOperator was missing
until apache#71738). Nothing else catches this: the Sphinx doc build only fails
on broken `:class:` refs, not on a class that's simply absent from the
table. This adds a regression test so the next missed operator fails CI
instead of relying on manual review.

@Lee-W Lee-W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a nice thing to have, but i think we should make it a prek hook instead of a unit test

@ColtenOuO ColtenOuO changed the title Add test to catch operators missing from common-ai docs index Add prek hook to catch operators missing from common-ai docs index Aug 24, 2026
@ColtenOuO

ColtenOuO commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing! Agree your point

I've updated it to a prek hook and also updated the PR title and description.

@ColtenOuO
ColtenOuO requested a review from Lee-W August 24, 2026 09:46

@Lee-W Lee-W left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one nits. LGTM

Comment thread scripts/ci/prek/check_common_ai_operators_index.py Outdated
A unit test only guards this when the provider's test suite happens to be
selected in CI, but the pairing it protects — the operators package and the
hand-maintained docs index — is just as likely to drift from a docs-only edit.
A prek hook keyed on both sides catches the gap at commit time instead.
@ColtenOuO
ColtenOuO force-pushed the common-ai-operators-index-test branch from b4425a1 to 842c37a Compare August 25, 2026 14:00
@potiuk
potiuk merged commit 7c2e201 into apache:main Aug 25, 2026
36 checks passed
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
…pache#71783)

* Add test to catch operators missing from common-ai docs index

The "Choosing the right operator" table in
providers/common/ai/docs/operators/index.rst is hand-maintained and has
already gone stale more than once (LLMSchemaCompareOperator was missing
until apache#71738). Nothing else catches this: the Sphinx doc build only fails
on broken `:class:` refs, not on a class that's simply absent from the
table. This adds a regression test so the next missed operator fails CI
instead of relying on manual review.

* Replace common-ai docs index test with a prek hook

A unit test only guards this when the provider's test suite happens to be
selected in CI, but the pairing it protects — the operators package and the
hand-maintained docs index — is just as likely to drift from a docs-only edit.
A prek hook keyed on both sides catches the gap at commit time instead.
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.

3 participants