fix(proposal): show not-found when requested proposal ID doesn't exist#398
Merged
Conversation
📊 Build Bundle StatsThe latest build generated the following assets: |
|
✅ No security or compliance issues detected. Reviewed everything up to 094a7e1. Security Overview
Detected Code Changes
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes proposal detail routing so missing or intentionally omitted proposal IDs show the existing not-found state instead of rendering the nearest lower proposal returned by list_proposals.
Changes:
- Filters
listProposalsresults inuseGovernanceProposalto only return proposals matching the requested ID. - Updates the proposal details route types/render guard to handle an undefined proposal response.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/governance-app-frontend/src/common/hooks/governance/useGovernanceProposal.ts |
Adds ID matching before returning a proposal from the range query. |
src/governance-app-frontend/src/routes/_auth/voting/proposals/$id/index.tsx |
Allows undefined proposal responses and avoids rendering details when absent. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
artkorotkikh-dfinity
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Landing on
/voting/proposals/:idwith an ID that doesn't exist (e.g. a manage-neuron proposal we don't surface) was rendering a different, neighboring proposal instead of a not-found state. The URL kept the requested ID but the content was for whichever existing proposal had ID ≤ the requested one. Easy repro: open https://dashboard.internetcomputer.org/proposal/141983 on the IC dashboard and click through to our app — you land on/voting/proposals/141983and see an unrelated proposal.Root cause:
useGovernanceProposalcallslistProposalswithbeforeProposal: proposalId + 1n, limit: 1. That's a range query, not a point lookup, so when the requested ID is missing the canister returns the next-lower existing proposal. The hook returnedres.proposals[0]without checking that the ID matched.Changes
matchesRequestedIdfilter inuseGovernanceProposalso a result whose ID doesn't match the requested one becomesundefined. Kept usinglist_proposals(notproposal_info) to preserveomitLargeFields.