Skip to content

OCPBUGS-76787: Fix 404 error when viewing CRs with 'All Projects' selected#16154

Open
rhamilto wants to merge 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-76787
Open

OCPBUGS-76787: Fix 404 error when viewing CRs with 'All Projects' selected#16154
rhamilto wants to merge 1 commit intoopenshift:mainfrom
rhamilto:OCPBUGS-76787

Conversation

@rhamilto
Copy link
Member

@rhamilto rhamilto commented Mar 16, 2026

Summary

Fixes a bug where navigating to custom resource lists with "All Projects" selected results in a 404 error.

Bug: OCPBUGS-76787
Affected version: 4.21.0
Regression: Yes (worked in 4.20.z)

Problem

When viewing custom resources like Certificates or StorageClusters with the project filter set to "All Projects", users encounter a 404 error. The issue occurs both:

  • When using the Search UI (Home > search > Resources > select "certificate")
  • When directly navigating to /k8s/all-namespaces/:plural URLs

Root Cause

The ResourceListPage and ResourceDetailsPage wrapper components were only using the namespace from URL params. For routes like /k8s/all-namespaces/:plural, there is no :ns parameter in the URL, so the namespace was undefined and not being resolved from the namespace selector.

Solution

Created a reusable useNamespaceFromURL hook that encapsulates the logic for determining the correct namespace. The hook:

  1. Routes with explicit namespace (/k8s/ns/:ns/:plural) → uses the URL param
  2. All-namespaces routes (/k8s/all-namespaces/:plural) → uses the active namespace from the selector
  3. ALL_NAMESPACES_KEY conversion → when active namespace is '#ALL_NS#', converts it to undefined so underlying components fetch from all namespaces

This matches the pattern used by SearchPage and provides a reusable solution for other components that need similar functionality.

Changes

  • New file: useNamespaceFromURL.ts - Custom hook for namespace resolution with proper ALL_NAMESPACES_KEY handling
  • Updated: ResourceListPage wrapper to use useNamespaceFromURL() hook
  • Updated: ResourceDetailsPage wrapper to use useNamespaceFromURL() hook

Test plan

  • All existing unit tests pass (190 tests)
  • No TypeScript errors
  • ESLint passes
  • Manual testing: Navigate to /k8s/all-namespaces/certificates with "All Projects" selected - should display certificates instead of 404
  • Manual testing: Navigate to /k8s/all-namespaces/certificates with a specific namespace selected - should display certificates from that namespace
  • Manual testing: Navigate to /k8s/ns/default/certificates - should continue to work as before (showing only default namespace)
  • Manual testing: Use Search UI to select a custom resource type with "All Projects" selected - should display resources

🤖 Generated with Claude Code

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 16, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-76787, which is invalid:

  • expected the bug to target the "4.22.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

Fixes a bug where navigating to custom resource lists with "All Projects" selected results in a 404 error.

Bug: OCPBUGS-76787
Affected version: 4.21.0
Regression: Yes (worked in 4.20.z)

Problem

When viewing custom resources like Certificates or StorageClusters with the project filter set to "All Projects", users encounter a 404 error. The issue occurs both:

  • When using the Search UI (Home > search > Resources > select "certificate")
  • When directly navigating to /k8s/all-namespaces/:plural URLs

Root Cause

The ResourceListPage and ResourceDetailsPage wrapper components were only using the namespace from URL params. For routes like /k8s/all-namespaces/:plural, there is no :ns parameter in the URL, resulting in undefined being passed as the namespace.

Solution

Modified the wrapper components to use the useActiveNamespace() hook as a fallback when the namespace isn't in the URL params. This matches the pattern used by SearchPage and ensures:

  • Routes with explicit namespace (/k8s/ns/:ns/:plural) continue to work as before
  • Routes for all namespaces (/k8s/all-namespaces/:plural) now correctly use the active namespace from the namespace selector

Changes

  • Updated ResourceListPage wrapper to use useActiveNamespace() fallback
  • Updated ResourceDetailsPage wrapper to use useActiveNamespace() fallback

Test plan

  • All existing unit tests pass (190 tests)
  • No TypeScript errors
  • ESLint passes
  • Manual testing: Navigate to /k8s/all-namespaces/certificates with "All Projects" selected - should display certificates instead of 404
  • Manual testing: Navigate to /k8s/ns/default/certificates - should continue to work as before
  • Manual testing: Use Search UI to select a custom resource type with "All Projects" selected - should display resources

🤖 Generated with Claude Code

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from Leo6Leo and spadgett March 16, 2026 19:21
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Mar 16, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhamilto

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 16, 2026
@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Mar 16, 2026
@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-76787, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

Summary

Fixes a bug where navigating to custom resource lists with "All Projects" selected results in a 404 error.

Bug: OCPBUGS-76787
Affected version: 4.21.0
Regression: Yes (worked in 4.20.z)

After

localhost_9000_search_all-namespaces_page=1 perPage=50 kind=cert-manager io%7Ev1%7ECertificate

Problem

When viewing custom resources like Certificates or StorageClusters with the project filter set to "All Projects", users encounter a 404 error. The issue occurs both:

  • When using the Search UI (Home > search > Resources > select "certificate")
  • When directly navigating to /k8s/all-namespaces/:plural URLs

Root Cause

The ResourceListPage and ResourceDetailsPage wrapper components were only using the namespace from URL params. For routes like /k8s/all-namespaces/:plural, there is no :ns parameter in the URL, resulting in undefined being passed as the namespace.

Solution

Modified the wrapper components to use the useActiveNamespace() hook as a fallback when the namespace isn't in the URL params. This matches the pattern used by SearchPage and ensures:

  • Routes with explicit namespace (/k8s/ns/:ns/:plural) continue to work as before
  • Routes for all namespaces (/k8s/all-namespaces/:plural) now correctly use the active namespace from the namespace selector

Changes

  • Updated ResourceListPage wrapper to use useActiveNamespace() fallback
  • Updated ResourceDetailsPage wrapper to use useActiveNamespace() fallback

Test plan

  • All existing unit tests pass (190 tests)
  • No TypeScript errors
  • ESLint passes
  • Manual testing: Navigate to /k8s/all-namespaces/certificates with "All Projects" selected - should display certificates instead of 404
  • Manual testing: Navigate to /k8s/ns/default/certificates - should continue to work as before
  • Manual testing: Use Search UI to select a custom resource type with "All Projects" selected - should display resources

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
  • Improved namespace resolution to automatically use your active namespace when not explicitly specified in the URL, while properly prioritizing directly provided namespace parameters.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from yapei March 16, 2026 19:23
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f6b0f09a-b710-488d-9061-39a1d42eb74c

📥 Commits

Reviewing files that changed from the base of the PR and between 092f737 and 2debd2b.

📒 Files selected for processing (1)
  • frontend/public/components/resource-list.tsx
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/resource-list.tsx
🧬 Code graph analysis (1)
frontend/public/components/resource-list.tsx (2)
frontend/public/components/namespace.jsx (1)
  • params (666-666)
frontend/public/components/resource-quota.jsx (1)
  • params (266-266)
🔇 Additional comments (3)
frontend/public/components/resource-list.tsx (3)

30-30: LGTM on the import.

Using the SDK's useActiveNamespace hook is the right approach—ensures consistent namespace resolution across all console components and aligns with how SearchPage already handles this scenario.


74-80: Solid fix for the undefined namespace case.

The fallback logic is clean: URL param takes precedence, active namespace provides the safety net for /k8s/all-namespaces/:plural routes. The inline comment is helpful for future maintainers.

One minor note: the || operator will also fallback if params.ns is an empty string. If you ever need to distinguish between "explicitly empty" vs "not present," you'd use params.ns ?? activeNamespace. Given the current routing patterns in Console, the || behavior here is likely what you want.


130-136: Consistent with ResourceListPage—good.

Same pattern applied to both wrapper components, which is exactly right. Both now handle the "All Projects" route gracefully.

If this pattern spreads to more components, consider extracting a small custom hook like useResolvedNamespace(params) to DRY it up, but for two usages this is perfectly maintainable.


📝 Walkthrough

Walkthrough

The change updates ResourceListPage and ResourceDetailsPage components to resolve namespace selection with improved fallback logic. The components now import useActiveNamespace from dynamic-plugin-sdk and implement a namespace resolution strategy where the URL parameter ns takes priority, falling back to the active namespace when absent. The resolved namespace value is then threaded through nested page components via the params object. No modifications to exported public signatures or APIs occurred; the update is limited to internal property passing and import statements.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

@rhamilto
Copy link
Member Author

/jira refresh

@openshift-ci-robot
Copy link
Contributor

@rhamilto: This pull request references Jira Issue OCPBUGS-76787, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.22.0) matches configured target version for branch (4.22.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

Details

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@rhamilto
Copy link
Member Author

/cherry-pick release-4.21

@openshift-cherrypick-robot

@rhamilto: once the present PR merges, I will cherry-pick it on top of release-4.21 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-4.21

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@rhamilto rhamilto force-pushed the OCPBUGS-76787 branch 2 times, most recently from cde3d05 to 76276ce Compare March 16, 2026 19:31
…ected

When navigating to resource lists with "All Projects" selected (e.g.,
/k8s/all-namespaces/certificates), the page was showing a 404 error.

The issue was that ResourceListPage and ResourceDetailsPage components
were not handling the namespace correctly for routes without an explicit
:ns parameter. For routes like /k8s/all-namespaces/:plural, there is no
:ns param in the URL, so these components need to get the namespace from
the active namespace selector.

The fix uses useActiveNamespace() hook as a fallback when the namespace
isn't in the URL params. The components now:
- Use namespace from URL params if present (e.g., /k8s/ns/default/:plural)
- Fall back to active namespace from the selector for all-namespaces routes
- Convert ALL_NAMESPACES_KEY ('#ALL_NS#') to undefined so that underlying
  components fetch resources from all namespaces

This matches the pattern used in SearchPage and ensures resource lists
display correctly in all scenarios.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@rhamilto
Copy link
Member Author

/retest

4 similar comments
@rhamilto
Copy link
Member Author

/retest

@rhamilto
Copy link
Member Author

/retest

@rhamilto
Copy link
Member Author

/retest

@rhamilto
Copy link
Member Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 18, 2026

@rhamilto: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-console 32d1cd6 link true /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants