Skip to content

Improve error messages by checking detail and error keys#1305

Merged
djdanielsson merged 3 commits into
redhat-cop:develfrom
djdanielsson:1267
Jun 16, 2026
Merged

Improve error messages by checking detail and error keys#1305
djdanielsson merged 3 commits into
redhat-cop:develfrom
djdanielsson:1267

Conversation

@djdanielsson

Copy link
Copy Markdown
Collaborator

The error handler only checked the msg key from async task results. Some modules (ansible.controller.role, ansible.hub.ah_collection) put their error information in the detail or error keys instead, resulting in unhelpful messages like "Module failed: 'detail'" or "Unknown Error".

Add fallback lookups for the detail and error keys before falling back to the generic Unknown Error message.

Fixes #1267
Fixes #1255

Made-with: Cursor

@djdanielsson djdanielsson requested a review from a team as a code owner March 17, 2026 18:00
vars:
__new_error:
ERROR_MESSAGE: "{{ __cas_job_async_result['msg'] | default('UNKNOWN ERROR') }}"
ERROR_MESSAGE: "{{ __cas_job_async_result['msg'] | default(__cas_job_async_result['detail'] | default(__cas_job_async_result['error'] | default('UNKNOWN ERROR'))) }}"

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.

Do we want to put all 3 if they are defined? instead of defaulting to one?

@djdanielsson

Copy link
Copy Markdown
Collaborator Author

I am wondering if #1299 would over ride this anyways... maybe we close this and I test out the other PR and merge that if it works

@djdanielsson djdanielsson disabled auto-merge March 18, 2026 13:24
@djdanielsson djdanielsson marked this pull request as draft March 18, 2026 13:24
@djdanielsson djdanielsson deleted the 1267 branch April 16, 2026 14:18
@djdanielsson djdanielsson restored the 1267 branch April 16, 2026 14:21
@djdanielsson djdanielsson reopened this Apr 16, 2026
@djdanielsson djdanielsson temporarily deployed to requires-approval April 16, 2026 14:22 — with GitHub Actions Inactive
@djdanielsson djdanielsson temporarily deployed to requires-approval April 16, 2026 15:57 — with GitHub Actions Inactive
The error handler only checked the msg key from async task results.
Some modules (ansible.controller.role, ansible.hub.ah_collection) put
their error information in the detail or error keys instead, resulting
in unhelpful messages like "Module failed: 'detail'" or "Unknown Error".

Add fallback lookups for the detail and error keys before falling back
to the generic Unknown Error message.

Fixes redhat-cop#1267
Fixes redhat-cop#1255

Made-with: Cursor
@djdanielsson

Copy link
Copy Markdown
Collaborator Author

Ported the detail / error key fallback from this PR into #1299 (error_handling branch) so it lives in the refactored handle_error.yml there.

Leaving this PR open as a fallback: if we decide not to merge #1299, we can still merge this small fix on its own.

Refs #1299

djdanielsson added a commit to djdanielsson/infra.aap_configuration that referenced this pull request May 29, 2026
…factor

Apply the same msg/detail/error lookup chain from redhat-cop#1305 to the
refactored handle_error.yml so modules that put errors in detail or
error keys still produce useful messages when redhat-cop#1299 merges.

Co-authored-by: Cursor <cursoragent@cursor.com>
@djdanielsson djdanielsson marked this pull request as ready for review June 16, 2026 13:38
@djdanielsson djdanielsson merged commit f5e6b47 into redhat-cop:devel Jun 16, 2026
1 check was waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants