Skip to content

Fix provider error messages rendering as a tuple instead of the value - #73296

Merged
kaxil merged 1 commit into
apache:mainfrom
astronomer:fix-exception-format-args
Sep 20, 2026
Merged

kaxil merged 1 commit into
apache:mainfrom
astronomer:fix-exception-format-args

Conversation

@kaxil

@kaxil kaxil commented Sep 17, 2026

Copy link
Copy Markdown
Member

Three raise sites pass %s-style format arguments to the exception constructor, which does not interpolate them. The extra arguments land in args[1:] and the message renders as a tuple repr, so the user sees the format string rather than their own values:

before  ('%s task failed as %s not found.', 'wait_for_drop', '/data/incoming/*.csv')
after   wait_for_drop task failed as /data/incoming/*.csv not found.

before  ('conf parameter should be JSON Serializable %s', {'customer': {1, 2}})
after   conf parameter should be JSON Serializable: {'customer': {1, 2}}

before  ('connection_config must be provided for %s', <StorageType.S3: 's3'>)
after   connection_config must be provided for s3

The self.log.info("%s completed successfully as %s found.", ...) on the line below the first one is correct and is left alone: Airflow's structlog processor applies msg % args, so the logging form interpolates. Only the exception constructor does not.

Two of the three lines had no test reading the message, and the connection_config is None branch was not reached by any test at all, so both now have one. The third already had two assertions, but they matched on a prefix that appears in the tuple repr as well and so passed either way; they now require the interpolated form, and fail without the fix.

Worth knowing before this is merged: it is coupled to #73076, which adds a prek hook plus generated/known_exception_format_args.txt recording exactly these three files at count 1, and says it does not fix them. Whichever lands second has to update the other -- if #73076 goes first, three counts need decrementing here; if this goes first, its allowlist is stale and the hook fails. I am happy to rebase on it in either order. Separately, #64941 moves datafusion/object_storage_provider.py into the amazon provider, so that one line may need rehoming.

@vatsrahul1001

Copy link
Copy Markdown
Contributor

Need to resolve conflict in test, otherwise LGTM!

@kaxil
kaxil force-pushed the fix-exception-format-args branch from 3e53736 to 280cdcb Compare September 20, 2026 11:58
@kaxil
kaxil merged commit 2f84606 into apache:main Sep 20, 2026
155 checks passed
@kaxil
kaxil deleted the fix-exception-format-args branch September 20, 2026 13:14
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.

2 participants