Skip to content

fix(tree): show missing checkout errors without stale loading - #2224

Open
nuclearcat wants to merge 2 commits into
kernelci:mainfrom
nuclearcat:fix/1630/tree-not-found
Open

nuclearcat wants to merge 2 commits into
kernelci:mainfrom
nuclearcat:fix/1630/tree-not-found

Conversation

@nuclearcat

@nuclearcat nuclearcat commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Opening a nonexistent branch such as stable/linux-5.925.y displayed the supplied commit hash, zero counts, comparison controls, a no-results warning, and a persistent Loading... message. The header came from the URL, while the failed summary left the history query disabled.

Return a specific API 404 for a missing tree, branch, or commit/tag within the selected origin. The summary, full-details, and latest-checkout endpoints share the existence check. Existing checkouts without results remain HTTP 200, and result filters do not determine existence. Successful data lookups need no extra queries; failed lookups use up to three existence queries over the existing checkout indexes. A query parameter can no longer override the branch in a direct URL.

The frontend shows one page-level error at the original URL, with a Back to Trees link. It hides unvalidated details and dependent history, avoids retrying 404 responses, and keeps placeholder data only while filtering the same checkout. Unknown-tree shortcuts use the same error view.

Part of #1630. This PR addresses the API and frontend behavior. Returning HTTP 404 for the initial SPA document and rejecting unsupported paths in nginx remain open under that issue.

How to test

  1. Run the frontend and API from this branch against a database containing a known tree and branch. Open /tree/stable/linux-5.925.y/29c6cdaac04a6989a7ed4ae4275ce4244e617f58?df%7Cbs%7CFAIL=true. Expect Branch not found, the requested branch/tree/origin, and a Back to Trees link. If the database has no stable tree, expect Tree not found instead. There should be no zero-count tabs, comparison control, history request, or lingering Loading....
  2. Start with a valid details URL. Change its tree, branch, and commit separately to nonexistent values. Verify the corresponding error and an API 404 in the Network panel. Also try /tree/unknown/master and the /checkout/ and /c/ shortcut routes. Click Back to Trees and confirm the selected origin is retained.
  3. Open a valid commit and tag. Apply filters that match nothing, and check a known checkout without builds. These should remain empty-result states, not missing-resource 404s.
  4. Run cd dashboard && pnpm exec playwright test e2e/tree-not-found.spec.ts with Vite running. These six deterministic browser tests intercept API responses and include client-side navigation from a valid cached checkout to a missing branch.
  5. With an isolated PostgreSQL database configured through DB_HOST, DB_PORT, DB_NAME, DB_USER, and DB_PASSWORD, run cd backend && poetry run pytest kernelCI_app/tests/integrationTests/treeNotFound_test.py --ds=kernelCI.test_settings -n 0 --reruns 0. This exercises real database queries and the API views, including tags, origin scoping, filters, empty checkouts, and branch-parameter precedence.

Validation

  • Frontend unit suite: 169 passed; production build and changed-file lint passed.
  • Backend unit suite: 1,071 passed; PostgreSQL regression suite: 21 passed; latest-checkout HTTP cases against CI checkout fixtures: nine passed; Ruff passed. The latest-checkout tests now verify returned identity instead of accepting an HTTP-200 error body as success.
  • Browser regression suite: six passed. The reported URL also rendered correctly against the real local Django API and PostgreSQL, with one summary request returning 404 and no history request.
  • API schema regenerated with the new 404 response contract.

Rendered before/after evidence is attached in a PR comment. The before image uses the original frontend with the reported HTTP-200 no-results response. The after image uses the changed frontend with the real local Django API and an isolated database containing a valid stable/linux-6.1.y checkout. Neither image is committed.

Distinguish absent tree resources from existing checkouts without results.
Stop rendering details and dependent history after a failed lookup, and
preserve the requested URL with a specific not-found message.

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
@nuclearcat

Copy link
Copy Markdown
Member Author

The before capture reproduces the supplied URL and text using the original frontend with a controlled no-results API response. The after capture uses the same URL and viewport against the changed frontend, real Django API, and isolated PostgreSQL. The API returns 404 with resource: "branch"; the browser makes no history request.

Before After
Before: nonexistent branch displays a commit, zero counts, warnings, and persistent Loading After: Branch not found with tree, branch, origin, and Back to Trees

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>

@felipebergamin felipebergamin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants