← Back to Pull requests

[AAP-82489] fix: show detailed error message on template launch failure #3617

Closed
unknown closed this pull request without merging on Sep 22, 2026 19:09 UTC
View on GitHub
unknown unknown commented on Sep 21, 2026 19:05 UTC
Author

Summary

When launching a Job/Workflow Job Template through the "Prompt on Launch"
wizard, a rejected launch (e.g. swapping a prompted credential for one of a
different type) showed only the generic HTTP reason phrase — "Bad Request" —
in the failure toast. The wizard's submit handler caught the RequestError
itself and displayed err.message only, discarding the API's parsed JSON
body (e.g. {"credentials": ["Cannot assign a Credential of kind \token\", ...]})
that contains the actual validation detail.

This fixes the toast to route the error through the existing
useAwxErrorMessageParser() / awxErrorAdapter, so the specific API
validation message is shown instead of the generic status text.

Root cause

Per AAP-82489, changing a credential to one of a different type at launch is
intentional backend behavior (documented since 2018 in
docs/prompting.md — a same-type replacement is required so a relaunch uses
the up-to-date credential). Engineering confirmed this in the Jira comments,
and the customer's original complaint about the block itself was later
withdrawn. The remaining, still-valid complaint was that the UI didn't
surface why the launch failed — just "Bad Request" — even though the API
already returns a specific, actionable message.

frontend/awx/resources/templates/TemplatePage/TemplateLaunchWizard.tsx's
handleSubmit wraps the launch postRequest in its own try/catch and
shows a toast built from err.message alone. Since it catches locally, the
error never reaches PageWizardProvider's own submitError state and its
RequestErrorAlert, and it also never runs the (JSON-aware) error adapter.

Type of Change

  • Bug fix
  • Risk Analysis - REQUIRED

  • Low — Narrowly scoped: one launch-failure toast handler in one wizard.
  • Testing

    Manual Testing

    1. Create a Job Template with "Prompt on launch" enabled for Credentials, with a default credential set.
    2. Launch the template and, on the Credentials prompt, swap the credential for one of a different credential type.
    3. Submit the wizard.
    4. Before this fix: the failure toast shows only "Bad Request". After this fix: the toast shows the specific validation message returned by the API (e.g. Cannot assign a Credential of kind \token\.).

    Regression test

    Added a test to TemplateLaunchWizard.test.tsx: mocks the launch POST returning a 400
    with a credentials validation array (the exact body from the Jira report)
    and asserts the toast's children is the specific message, not the generic
    status text.

    Mutation testing: the workflow's automated mutation-test script errored
    on reverse-applying the fix patch (unrelated tooling issue), so I verified
    manually — checked out the pre-fix version of the source file and confirmed
    the new test fails, then restored the fix and confirmed it (and the other 19
    tests in the file) pass.

    Similar bug detection: the same pattern (error instanceof Error &&
    error.message
    swallowing a RequestError's JSON body in a toast) appears
    in ~29 other call sites across awx/eda/hub, e.g.
    frontend/awx/resources/templates/hooks/useLaunchTemplate.tsx:52 and
    frontend/awx/resources/templates/TemplatePage/RelaunchTemplateWithPasswords.tsx:65.
    Out of scope for this fix — noting for future cleanup.

    <img width="1383" height="632" alt="Screenshot 2026-09-21 at 10 18 10 AM" src="https://github.com/user-attachments/assets/4a84ee2b-74fe-44dd-999f-8143a14f7aa0" />

    Assisted-by: Claude Code / Sonnet 5 (Anthropic)

    Diff: 448 lines (+336 / -112) across 5 files Reviewer: keithjgrant Review duration: 1444m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 448 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.365
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3617"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.4% (MEDIUM) · Higher = larger blast radius
    45.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.9% · Safe to merge
    17.9%