extend delegation problem with reasoncodes for systemuser delegation - #2387
Conversation
…ion package and resource name
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
ChangesDelegation reason forwarding
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Auth as Upstream AUTH
participant Mapper as ProblemMapper
participant ErrorView as DelegationCheckError
participant Catalog as Access package and resource data
Auth->>Mapper: Return problem with delegationReasons
Mapper->>Mapper: Extract configured extension
Mapper->>ErrorView: Provide ProblemDetail with delegationReasons
ErrorView->>Catalog: Resolve package or resource identifiers
ErrorView->>ErrorView: Map reason codes and render details
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR extends the delegation error surface from the backend to the frontend by forwarding and rendering an upstream problem “extension” field (delegationReasons) so delegation/approval failures can show the concrete failing package/right and reason.
Changes:
- Added
delegationReasons?: stringto the frontendProblemDetailmodel and rendered it inDelegationCheckError. - Added styling for multi-line reason text in the error alert (
white-space: pre-line). - Updated backend
ProblemMapper.MapToAuthUiErrorto forward selected upstream problem extension members (currentlydelegationReasons), and adjusted tests to use the new return type.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/features/amUI/systemUser/types.ts | Adds delegationReasons to the problem type used by system user UI. |
| src/features/amUI/systemUser/components/DelegationCheckError/DelegationCheckError.tsx | Displays forwarded delegation reasons in the error alert. |
| src/features/amUI/systemUser/components/DelegationCheckError/DelegationCheckError.module.css | Styles the delegated reason details for readability (multi-line). |
| backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Tests/Helpers/ProblemMapperTest.cs | Updates tests to use ProblemInstance return type. |
| backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Helpers/ProblemMapper.cs | Forwards selected upstream problem extensions (e.g. delegationReasons) when mapping AUTH problems. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/features/amUI/systemUser/components/DelegationCheckError/DelegationCheckError.tsx`:
- Around line 101-115: Harden the reasons.map rendering in DelegationCheckError
against malformed entries by validating that each reason is an object with a
usable codes array before iterating, and provide a safe fallback for invalid
entries. Update package handling to fall back to reason.id when the package is
missing, and resolve unknown ReasonErrorMap codes without throwing while
preserving the existing translated-message format; also include package codes if
the payload provides them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b9ea282a-28cd-49ea-bfb4-4f6099c0deeb
📒 Files selected for processing (12)
backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Constants/Problem.csbackend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Helpers/ProblemMapper.cssrc/features/amUI/systemUser/CreateSystemUserPage/RightsIncluded.tsxsrc/features/amUI/systemUser/SystemUserAgentDelegationPage/SystemUserAgentDelegationPageContent.tsxsrc/features/amUI/systemUser/SystemUserAgentRequestPage.tsxsrc/features/amUI/systemUser/SystemUserChangeRequestPage.tsxsrc/features/amUI/systemUser/SystemUserRequestPage.tsxsrc/features/amUI/systemUser/components/DelegationCheckError/DelegationCheckError.tsxsrc/features/amUI/systemUser/errorHandling.tssrc/localizations/en.jsonsrc/localizations/no_nb.jsonsrc/localizations/no_nn.json
🚧 Files skipped from review as they are similar to previous changes (1)
- backend/src/Altinn.AccessManagement.UI/Altinn.AccessManagement.UI.Core/Helpers/ProblemMapper.cs
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/features/amUI/systemUser/components/DelegationCheckError/DelegationCheckError.tsx`:
- Around line 151-153: Update the single-code branch in DelegationCheckError to
pass the result of mapErrorCodeToErrorMessage through the existing translation
function t(), matching the multi-code branch, so single-reason errors render
localized text rather than the raw translation key.
- Around line 143-149: Add a stable key prop to each DsListItem returned by the
codes.map callback in DelegationCheckError, using the mapped code value or
another unique identifier already available in that iteration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: d275497a-b39d-40ac-9077-e3a39532ef85
📒 Files selected for processing (6)
src/features/amUI/systemUser/SystemUserAgentDelegationPage/SystemUserAgentDelegationPageContent.tsxsrc/features/amUI/systemUser/SystemUserAgentRequestPage.tsxsrc/features/amUI/systemUser/components/DelegationCheckError/DelegationCheckError.tsxsrc/localizations/en.jsonsrc/localizations/no_nb.jsonsrc/localizations/no_nn.json
🚧 Files skipped from review as they are similar to previous changes (5)
- src/features/amUI/systemUser/SystemUserAgentRequestPage.tsx
- src/localizations/no_nn.json
- src/features/amUI/systemUser/SystemUserAgentDelegationPage/SystemUserAgentDelegationPageContent.tsx
- src/localizations/en.json
- src/localizations/no_nb.json
|



extend delegation problem with reasoncodes and actual failing delegation package and resource name
Description
Related Issue(s)
Verification
Documentation
Summary by CodeRabbit