[AAP-92776] fix: guard remaining job output links with numeric id check #3736
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.
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.
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.
 Quality Gate passed
Issues
 0 New issues
 0 Accepted issues
Measures
 0 Security Hotspots
 92.9% Coverage on New Code
 0.0% Duplication on New Code
<!-- sqra-placement-anchor -->
See analysis details on SonarQube Cloud
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).
/run-playwright
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-ui-playwright-shard-summary -->
keithjgrant
Summary
Two remnants of the AAP-90710 / #3537 fix still produced Job Output links with a literal
:idwhen a job summary object (current_job/last_job) was truthy but lacked a numericid:ProjectDetails.tsxbuilt the Job Output link fromcurrent_job?.id ?? last_job?.idwhile gating visibility on object truthiness, so an id-less job object still rendered a broken link.InventorySourceDetails.tsxhad the same gap, and wrappedStatusCellin aLinkinstead of usingStatusCell.to.Both now use the shared
getSyncJobIdhelper (already used by the list columns fixed in #3667) to guard link rendering on a validated numeric id, and render viaStatusCell.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'sPageDetailJobStatus(constructed inventory "Last job status").Root Cause
All three components reconstructed Job Output links by checking truthiness of a
current_job/last_jobsummary object instead of validating that the object has a numeric id.useGetPageUrlsilently leaves an unsubstituted:idtoken in the path when the param isundefined, 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/JobOutputusages infrontend/: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 checkcurrent_jobtruthiness, but only to read.statusfor 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.pyagainst 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
Risk Analysis - REQUIRED
Dependencies
None.
Testing
Ephemeral E2E Tests
Once PR is ready and preliminary checks pass, trigger tests by posting a comment
/run-playwrighton this PR.Manual Testing
npx tsc --noEmit— clean on touched filesnpx eslint --config eslint.guardrails.config.mjs— no new warnings (pre-existingmax-lines-per-functionwarnings on all three files, unchanged in count)npx prettier --check— cleannpx vitest run frontend/awx/resources/inventories frontend/awx/resources/projects— 361/361 passing, including 3 new regression tests reproducing each bugScreenshots
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>