← Back to Pull requests

[AAP-92776] fix: guard remaining job output links with numeric id check #3736

Open
keithjgrant opened this pull request with 165 lines diff across 6 files
View on GitHub
keithjgrant keithjgrant commented on Oct 08, 2026 16:28 UTC
Author

Summary

Two remnants of the AAP-90710 / #3537 fix still produced Job Output links with a literal :id when a job summary object (current_job/last_job) was truthy but lacked a numeric id:

  • ProjectDetails.tsx built the Job Output link from current_job?.id ?? last_job?.id while gating visibility on object truthiness, so an id-less job object still rendered a broken link.

  • InventorySourceDetails.tsx had the same gap, and wrapped StatusCell in a Link instead of using StatusCell.to.
  • Both now use the shared getSyncJobId helper (already used by the list columns fixed in #3667) to guard link rendering on a validated numeric id, and render via StatusCell.to.

    While scanning for the same pattern elsewhere (see Similar Bug Detection below), a third, previously-unreported instance was found and fixed in InventoryDetails.tsx's PageDetailJobStatus (constructed inventory "Last job status").

    Root Cause

    All three components reconstructed Job Output links by checking truthiness of a current_job/last_job summary object instead of validating that the object has a numeric id. useGetPageUrl silently leaves an unsubstituted :id token in the path when the param is undefined, so the link renders but points at a broken URL instead of failing loudly.

    Similar Bug Detection

    Searched for the same truthy-object-instead-of-id-guard pattern across current_job/last_job/JobOutput usages in frontend/:

  • InventoryDetails.tsx:70-72 (PageDetailJobStatus) — same bug class, fixed in this PR.

  • useInventoryActions.tsx:199-201, useCancelInventoryUpdate.tsx:33-34, useInventorySourceActions.tsx:112-138 — also check current_job truthiness, but only to read .status for cancel-button visibility or to call the cancel API with the job's own id; they don't construct a Job Output link, so they're a different (lower-risk) pattern and out of scope here.
  • Mutation Testing

    Ran mutation-test.py against each fix commit, reverse-applying the fix and confirming the paired regression test fails without it:

  • fix(awx): guard remaining job output links with numeric id check → PASS (regression test correctly fails without the fix)

  • fix(awx): guard inventory details job output link with numeric id check → PASS (regression test correctly fails without the fix)
  • Type of Change

  • Bug fix

  • Tests
  • Risk Analysis - REQUIRED

  • High

  • Medium

  • Low — Narrowly scoped to three detail-page "Last job status" cells; no shared framework, routing, or API changes.
  • Dependencies

    None.

    Testing

    Ephemeral E2E Tests

    Once PR is ready and preliminary checks pass, trigger tests by posting a comment /run-playwright on this PR.

    Manual Testing

  • npx tsc --noEmit — clean on touched files

  • npx eslint --config eslint.guardrails.config.mjs — no new warnings (pre-existing max-lines-per-function warnings on all three files, unchanged in count)

  • npx prettier --check — clean

  • npx vitest run frontend/awx/resources/inventories frontend/awx/resources/projects — 361/361 passing, including 3 new regression tests reproducing each bug

  • Regression tests validated via mutation testing (see above) — each fails without its paired fix
  • Screenshots

    Not applicable — the bug only manifests as a broken href (.../jobs/inventory/:id/output), not a visual difference.

    Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

    Diff: 165 lines (+136 / -29) across 6 files Reviewer: keithjgrant Review duration: 2329m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.55) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.55 · 165 lines diff across 6 files
    0.55
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 5 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    83%
    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.306
    Self Review self_review
    0.140
    Real PR Conversation Timeline
    9 items
    nixocio nixocio commented on Oct 08, 2026 18:17 UTC
    Contributor

    CI is failing in useAutomationLeaderboardsView.test.tsx because two changes were combined: https://github.com/ansible/ansible-ui/pull/3703 made user_organization required, while https://github.com/ansible/ansible-ui/pull/3721 added two fixture rows without it. Those rows were later fixed in devel by https://github.com/ansible/ansible-ui/pull/3651. Please rebase this branch onto devel and rerun CI. This PR shouldn't need any code changes for that failure.

    redhat-chai-bot redhat-chai-bot commented on Oct 08, 2026 19:17 UTC
    Reviewer

    I found one correctness issue in the inventory-source fallback path. The remaining checks are green, but this should be addressed before merge.

    ---
    AI-generated. Review for accuracy.

    redhat-chai-bot redhat-chai-bot commented on code on Oct 08, 2026 19:17 UTC
    Code Review
    frontend/awx/resources/inventories/inventorySources/InventorySourceDetails.tsx:1
    @@ -178,19 +181,16 @@ export function InventorySourceDetails(
               inventorySource.name
             )}
           </PageDetail>
    -      {lastJob ? (
    +      {lastJobId !== undefined ? (
             <PageDetail label={t`Last job status`}>
    -          <Link
    +          <StatusCell
    +            tooltip={<LastJobTooltip job={{ ...lastJob, id: lastJobId }} />}

    P1: lastJobId can come from current_update.id or related.last_job, while lastJob is populated only from summary_fields.current_job / summary_fields.last_job. In that case this renders LastJobTooltip with only { id }; the tooltip calls job.status.toUpperCase(), so hovering the status causes a TypeError. Please guard the tooltip/rendering on a complete job object or populate it from the same fallback, and add a regression test for a numeric fallback ID with no summary job.

    ---
    AI-generated. Review for accuracy.

    keithjgrant keithjgrant commented on code on Oct 08, 2026 20:55 UTC
    Code Review
    frontend/awx/resources/inventories/inventorySources/InventorySourceDetails.tsx:1
    @@ -178,19 +181,16 @@ export function InventorySourceDetails(
               inventorySource.name
             )}
           </PageDetail>
    -      {lastJob ? (
    +      {lastJobId !== undefined ? (
             <PageDetail label={t`Last job status`}>
    -          <Link
    +          <StatusCell
    +            tooltip={<LastJobTooltip job={{ ...lastJob, id: lastJobId }} />}

    Good catch — fixed in 0f8ffb9b0. lastJob is now only used to build the tooltip when it actually has a status (via a new buildLastJobTooltip helper); when lastJobId resolves solely from current_update/related.last_job with no summary job object, we skip the tooltip instead of rendering it with just { id }. Added a regression test in f9dccae43 that reproduces the TypeError on hover and fails without the fix (verified via mutation testing).

    keithjgrant keithjgrant commented on Oct 08, 2026 21:03 UTC
    Author

    /run-playwright

    redhat-chai-bot redhat-chai-bot commented on code on Oct 08, 2026 21:06 UTC
    Code Review
    frontend/awx/resources/inventories/inventorySources/InventorySourceDetails.tsx:1
    @@ -178,19 +181,16 @@ export function InventorySourceDetails(
               inventorySource.name
             )}
           </PageDetail>
    -      {lastJob ? (
    +      {lastJobId !== undefined ? (
             <PageDetail label={t`Last job status`}>
    -          <Link
    +          <StatusCell
    +            tooltip={<LastJobTooltip job={{ ...lastJob, id: lastJobId }} />}

    The buildLastJobTooltip guard looks correct — only constructing the tooltip when a real status exists avoids the TypeError path cleanly. The regression test covering the numeric-fallback-ID-without-summary-job scenario is exactly what was needed. Thanks for the quick fix! 👍

    ---
    AI-generated. Review for accuracy.

    aap-pde-ci-bot aap-pde-ci-bot commented on Oct 08, 2026 23:21 UTC
    Bot

    <!-- aap-ui-playwright-shard-summary -->

    Currents dashboard

    Reviewers
    Assignees
    keithjgrant keithjgrant
    Labels
    risk: low confidence: 83.9% 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: 54.9% (MEDIUM) · Higher = larger blast radius
    54.9%
    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: 83.9% · Lower = rushed or shallow review
    83.9%
    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: 8.8% · Safe to merge
    8.8%