Skip to content

Improve SnowflakeSqlApiOperator error message on query status check failure#66642

Merged
potiuk merged 1 commit into
apache:mainfrom
justinpakzad:fix/snowflake-missing-query-status-on-poll-error
Jun 5, 2026
Merged

Improve SnowflakeSqlApiOperator error message on query status check failure#66642
potiuk merged 1 commit into
apache:mainfrom
justinpakzad:fix/snowflake-missing-query-status-on-poll-error

Conversation

@justinpakzad

@justinpakzad justinpakzad commented May 10, 2026

Copy link
Copy Markdown
Contributor

Replace ValueError with RuntimeError on query status check failure in poll_on_queries, including the query id and original error for better debuggability. Added a new test to ensure a RuntimeError is raised when status check fails.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@justinpakzad justinpakzad requested a review from potiuk as a code owner May 10, 2026 01:00
@boring-cyborg boring-cyborg Bot added area:providers provider:snowflake Issues related to Snowflake provider labels May 10, 2026

@jroachgolf84 jroachgolf84 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.

I think this is an interesting one to think more about. So, the exception that is being thrown is from a failure when hitting the Snowflake API, not a failure of the query.

I'm not sure that it makes sense to remove the query and mark the statement as being failed. For example, what if your creds expire? This would cause the status check to fail even if the statement is running correctly. Your unit test captures this scenario (connection timing out) which doesn't mean that the query failed.

@jroachgolf84

Copy link
Copy Markdown
Collaborator

@justinpakzad - I think it might make sense to raise a more specific exception rather than just a ValueError. Thoughts?

@justinpakzad

justinpakzad commented May 10, 2026

Copy link
Copy Markdown
Contributor Author

@justinpakzad - I think it might make sense to raise a more specific exception rather than just a ValueError. Thoughts?

Hey, thanks for the review. To address your first comment - that's a good point, slipped over my head a bit that there is a distinction between a query failure and other types of errors that don't necessarily mean there was a failure on the query end (as you mentioned). Are you suggesting we just revert it back but maybe with something like:

try:
    statement_status = self._hook.get_sql_api_query_status(query_id)
except Exception as e:
    raise RuntimeError(f"Failed to get status for query {query_id}: {e}") from e

@justinpakzad justinpakzad marked this pull request as draft May 10, 2026 03:07
@jroachgolf84

Copy link
Copy Markdown
Collaborator

Yes, I think that would make sense!

@justinpakzad justinpakzad force-pushed the fix/snowflake-missing-query-status-on-poll-error branch from c03ce37 to 6348406 Compare May 10, 2026 04:55
@justinpakzad justinpakzad changed the title Fix SnowflakeSqlApiOperator losing query status on poll error Improve SnowflakeSqlApiOperator error message on query status check failure May 10, 2026
@justinpakzad justinpakzad marked this pull request as ready for review May 10, 2026 05:02

@jroachgolf84 jroachgolf84 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.

Thanks for the change, this LGTM!

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label May 24, 2026
@potiuk

potiuk commented May 26, 2026

Copy link
Copy Markdown
Member

@justinpakzad This PR has had no author response for 15 days since the last maintainer comment, and the branch now has failing CI. Closing to keep the queue clean.

When you're ready to resume, please rebase onto the current main branch, address any failing checks, and either reopen this PR or open a fresh one. There is no rush.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.


Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting

@potiuk potiuk closed this May 26, 2026
@justinpakzad

justinpakzad commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

@potiuk, not sure why this got closed, I was awaiting a review (it got tagged yesterday as ready for review) and would have happily just rebased (nothing was failing to begin with, just outdated branch). Anyways, was a tiny change so not really that important but maybe just a reminder next time instead of instant closure.

@potiuk potiuk reopened this May 28, 2026
@potiuk

potiuk commented May 28, 2026

Copy link
Copy Markdown
Member

@potiuk, not sure why this got closed, I was awaiting a review (it got tagged yesterday as ready for review) and would have happily just rebased (nothing was failing to begin with, just outdated branch). Anyways, was a tiny change so not really that important but maybe just a reminder next time instead of instant closure.

My mistake, sorry

potiuk added a commit to apache/airflow-steward that referenced this pull request May 28, 2026
…#368)

Sweep 4 (stale ready-for-review label) in stale-sweeps.md proposes
`strip-ready-label` (4a, healthy branch) or `close` (4b, rotted
branch) when a PR carries the `ready for maintainer review` label,
a maintainer commented ≥ 7 days ago, and the author has been
silent since.

The "maintainer commented ≥ 7 days ago" check was naive: it counted
ANY maintainer comment older than 7 days, including ones that
predate the `ready for maintainer review` label-add. So a PR that
was promoted to ready on day N could be closed by Sweep 4b on day
N+2 — because the maintainer comment that initially nudged the
contributor (and that the contributor's eventual fix addressed,
leading to the promotion) was now > 7 days old and the contributor
was, by definition, "silent" since.

This is backwards. When the `ready for maintainer review` label is
added, the queue moves to the maintainers; the author has nothing
they need to reply to. Pre-label maintainer comments are part of
the conversation that *got* the PR to ready, not evidence of
silence on something the author still owes.

== Fix ==

Sweep 4's "Common trigger" now requires the qualifying maintainer
comment to have come AFTER the label was added:

  last_maintainer_comment_at > ready_label_added_at

`ready_label_added_at` is the most recent
`LabeledEvent { label.name == "ready for maintainer review" }`
timestamp from the PR's `timelineItems`. If no maintainer has
commented post-promotion, the sweep doesn't fire at all — the
queue is on the maintainers, not the contributor.

The new guard mirrors the "after the label-add timestamp" pattern
that classify-and-act.md row F4 already uses for regression
detection, so the convention is consistent across the skill.

== Live incident motivating the fix ==

apache/airflow#66642 — contributor was promoted to
`ready for maintainer review` on 2026-05-24, closed by this
skill on 2026-05-26 with *"no author response for 15 days since
the last maintainer comment"*. The cited maintainer comment was
from 2026-05-11, well before the promotion. Contributor pushed
back politely; PR reopened 2026-05-28; this is the skill-side fix.

== Verification ==

`skill-and-tool-validate` exits 0.

Generated-by: Claude Code (Opus 4.7)
@justinpakzad justinpakzad force-pushed the fix/snowflake-missing-query-status-on-poll-error branch from 6348406 to 605de3c Compare May 29, 2026 00:25
@justinpakzad

justinpakzad commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

My mistake, sorry

No worries at all! Thanks for re-opening.

@justinpakzad

Copy link
Copy Markdown
Contributor Author

@potiuk, can you give this a review please? Thanks.

@justinpakzad justinpakzad force-pushed the fix/snowflake-missing-query-status-on-poll-error branch from 605de3c to 1d0a7c2 Compare June 5, 2026 11:39

@potiuk potiuk 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.

LGTM — RuntimeError with the query id and from e chaining is a clear improvement over ValueError({...}), which used the wrong type and buried the cause in a dict. It's consistent with the RuntimeError already raised a few lines up for the error status, and nothing was catching the old exception, so no behavior breakage. Nice that you added a test for it. Thanks!


Drafted-by: Claude Code (Opus 4.8); reviewed by @potiuk before posting

@potiuk potiuk merged commit 5dde3cd into apache:main Jun 5, 2026
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:snowflake Issues related to Snowflake provider ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants