Skip to content

Improve error messages by checking detail and error keys#1305

Draft
djdanielsson wants to merge 3 commits intoredhat-cop:develfrom
djdanielsson:1267
Draft

Improve error messages by checking detail and error keys#1305
djdanielsson wants to merge 3 commits intoredhat-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
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
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
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