Skip to content

feat(iswf): Adds exceptions_to_silence parameter to tasks, exposes this and report_timeout_errors in task registration#608

Open
GabeVillalobos wants to merge 6 commits intomainfrom
gv/retry-logic-parity
Open

feat(iswf): Adds exceptions_to_silence parameter to tasks, exposes this and report_timeout_errors in task registration#608
GabeVillalobos wants to merge 6 commits intomainfrom
gv/retry-logic-parity

Conversation

@GabeVillalobos
Copy link
Copy Markdown
Member

@GabeVillalobos GabeVillalobos commented Apr 27, 2026

Exposes the previously added report_timeout_errors via task registration method.

Adds a new exceptions_to_silence parameter, which should put us at feature parity with the remainder of fields in @retry:

| Parameter          | Retry | Report | Raise | Description |
|--------------------|-------|--------|-------|-------------|
| on                 | Yes   | Yes    | No    | Exceptions that will trigger a retry & report to Sentry. |
| on_silent          | Yes   | No     | No    | Exceptions that will trigger a retry but not be captured to Sentry. |
| exclude            | No    | No     | Yes   | Exceptions that will not trigger a retry and will be raised. |
| ignore             | No    | No     | No    | Exceptions that will be ignored and not trigger a retry & not report to Sentry. |
| ignore_and_capture | No    | Yes    | No    | Exceptions that will not trigger a retry and will be captured to Sentry. |

To emulate each of these previous parameters:
on

namespace.register(
    ...,
    retry=Retry(times=3, on=(MyCoolException,)),
)

on_silent

namespace.register(
    ...,
    retry=Retry(times=3, on=(MyCoolException,)),
    exceptions_to_silence(MyCoolException,)
)

exclude

namespace.register(
    ...,
    retry=Retry(times=3, on=(...), ignore=(IgnoreMeException,)),
)

ignore

namespace.register(
    ...,
    retry=Retry(times=3, ignore=(IgnoreMeException,)),
    exceptions_to_silence(IgnoreMeException,)
)

ignore_and_capture
.... It's actually not entirely clear to me how this is supposed to behave compared to exclude

@GabeVillalobos GabeVillalobos marked this pull request as ready for review April 28, 2026 17:03
@GabeVillalobos GabeVillalobos requested a review from a team as a code owner April 28, 2026 17:03
wait_for_delivery: bool = False,
compression_type: CompressionType = CompressionType.PLAINTEXT,
report_timeout_errors: bool = True,
exceptions_to_silence: tuple[type[BaseException], ...] | None = None,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This name is a little verbose, but the intention here is just to silence sentry errors for some list of exceptions. It should give us the blanket coverage to phase out the remaining options in our retry decorators.

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.

What about expected_errors? These are errors we expect to happen and don't need observability into.

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.

Could these new parameters be added to the docstring as well?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call, just renamed this and added docstring comments.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7aa4820. Configure here.

Comment thread clients/python/src/taskbroker_client/worker/workerchild.py
@markstory
Copy link
Copy Markdown
Member

ignore_and_capture

Can this state just cease to exist? There is a single usage of it in sentry.

@GabeVillalobos GabeVillalobos force-pushed the gv/retry-logic-parity branch 2 times, most recently from abc6bda to cfe0c37 Compare April 29, 2026 20:03
Comment on lines 283 to 290
at_most_once=at_most_once,
wait_for_delivery=wait_for_delivery,
compression_type=compression_type,
report_timeout_errors=report_timeout_errors,
expected_exceptions=expected_exceptions,
)
self._registered_tasks[name] = task
return task
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The new expected_exceptions and report_timeout_errors parameters on ExternalNamespace.register() have no effect because ExternalTask instances are not executed locally.
Severity: MEDIUM

Suggested Fix

Raise a TypeError or ValueError if expected_exceptions or report_timeout_errors are passed to ExternalNamespace.register(), as these parameters are not supported for external tasks. Alternatively, document this limitation clearly in the method's docstring to prevent misuse.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: clients/python/src/taskbroker_client/registry.py#L283-L290

Potential issue: The `ExternalNamespace.register()` method now accepts
`expected_exceptions` and `report_timeout_errors` parameters. However, these are
silently ignored for external tasks. These parameters control task execution behavior,
but `ExternalTask` instances are only dispatched, not executed, by the local worker; the
remote application's task registration governs error handling. A developer setting
`expected_exceptions` on an external task stub will incorrectly believe they have
suppressed certain error reports, when in fact the setting has no effect at runtime.

Did we get this right? 👍 / 👎 to inform future reviews.

@GabeVillalobos
Copy link
Copy Markdown
Member Author

Can this state just cease to exist? There is a single usage of it in sentry.

@markstory Yeah we can. I think this change still make sense, excluding that use case, since we won't always want to be notified if we retry a retriable exception.

Copy link
Copy Markdown
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

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

Could you add some tests for this behaviour?

@GabeVillalobos GabeVillalobos force-pushed the gv/retry-logic-parity branch from cfe0c37 to 24f66a6 Compare April 30, 2026 22:51
@GabeVillalobos
Copy link
Copy Markdown
Member Author

@evanh Added some testing. I think this should cover the major use cases we care about, but can add more if needed.

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.

3 participants