Repository navigation
Register getGraph custom action for Radius.Core/applications - #11796
Conversation
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/e1c7bbde-4acb-4a40-bb4b-9fd144c45720 Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
getGraph route to prevent 404 error|
@copilot - should the new controller follow the file path conventions established in |
…ackage Agent-Logs-Url: https://github.com/radius-project/radius/sessions/0c0e5b95-aebe-4afe-a2a7-8883992757a8 Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
Good catch — moved the new controller into |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Co-authored-by: Will <28876888+willtsai@users.noreply.github.com> Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11796 +/- ##
==========================================
+ Coverage 51.19% 51.40% +0.20%
==========================================
Files 715 716 +1
Lines 45081 45106 +25
==========================================
+ Hits 23079 23186 +107
+ Misses 19803 19721 -82
Partials 2199 2199 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agent-Logs-Url: https://github.com/radius-project/radius/sessions/f712a215-1e29-4b59-8f6f-32984cbd8a6b Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
Added a test for the Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot - are you able to view the codecov report via this link to review and improve the test coverage as called out by the report? |
|
This is now ready for review. I've built and validated that this works, see below. Radius v0.56.1 Radius build of this branch |
There was a problem hiding this comment.
Pull request overview
This PR fixes the Radius.Core/applications/{app}/getGraph custom action returning 404 by wiring the custom action into the Radius.Core namespace builder, adding a v20250801preview controller for the action, and extracting shared graph-computation logic so both Applications.Core and Radius.Core controllers reuse it.
Changes:
- Register
getGraphas a custom action onRadius.Core/applicationsinSetupRadiusCoreNamespace. - Add a
v20250801previewgetGraph controller forRadius.Core/applicationsand route it to shared graph computation. - Extract
ComputeGraphResponsehelper and expand unit/router tests for both namespaces and error/success paths.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/corerp/setup/setup.go | Registers getGraph custom action for Radius.Core/applications and wires it to the new controller. |
| pkg/corerp/setup/setup_test.go | Adds router assertion coverage for POST .../radius.core/applications/{app}/getgraph resolving to ACTIONGETGRAPH. |
| pkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go | Introduces Radius.Core v20250801preview getGraph controller delegating to shared graph logic. |
| pkg/corerp/frontend/controller/applications/v20250801preview/getgraph_test.go | Adds unit tests for not-found, DB error propagation, and success path for the new controller. |
| pkg/corerp/frontend/controller/applications/getgraph.go | Extracts ComputeGraphResponse helper used by both getGraph controllers. |
| pkg/corerp/frontend/controller/applications/getgraph_test.go | Adds targeted unit tests to cover ComputeGraphResponse error paths and controller DB/success paths. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Will <28876888+willtsai@users.noreply.github.com>
…GraphResponse Switch from resources.Parse to resources.ParseResource for environment ID validation to ensure the stored value is a named resource (not a collection or custom-action ID). Wrap the error with fmt.Errorf for context. Agent-Logs-Url: https://github.com/radius-project/radius/sessions/45f8841e-e581-446f-ade0-d08975e20c38 Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
…Response Agent-Logs-Url: https://github.com/radius-project/radius/sessions/8499b137-8284-46a8-ad5c-77cc8ad25c61 Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
…project#11796) # Description `POST .../providers/Radius.Core/applications/{app}/getGraph` returned 404 because the namespace builder for `Radius.Core` never wired the `getGraph` custom action — only `Applications.Core/applications` did. The OpenAPI route exists but had no controller, blocking app graph rendering in the dashboard. - **New controller**: `GetGraphv20250801preview` in `pkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go` (package `v20250801preview`). Placed in a `v20250801preview/` subpackage to match the convention established by `pkg/corerp/frontend/controller/environments/v20250801preview/`. Typed against `datamodel.Application_v20250801preview` and uses the `Application20250801*` converters. - **Shared helper**: Extracted a `ComputeGraphResponse` exported helper in the parent `pkg/corerp/frontend/controller/applications` package so both the `Applications.Core` and `Radius.Core` getGraph controllers reuse the same graph-listing logic (resource type discovery, application-/environment-scoped listing, and graph computation) without duplication. - **Stricter validation**: `ComputeGraphResponse` uses `resources.ParseResource` (instead of `resources.Parse`) to validate the environment ID is a named resource, rejecting collection or custom-action IDs. The error is wrapped with `fmt.Errorf` for context. - **Wiring**: `SetupRadiusCoreNamespace` in `pkg/corerp/setup/setup.go` now registers `Custom["getGraph"]` on the `applications` resource, analogous to the `Applications.Core/applications` registration. - **Tests**: Unit test for the not-found path on the new controller, plus a router assertion in `setup_test.go` that `POST .../radius.core/applications/app0/getgraph` resolves to `ACTIONGETGRAPH`. Additional tests targeting the lines flagged by Codecov: - `ComputeGraphResponse` invalid-environment-ID error path. - `ComputeGraphResponse` UCP error-propagation path, driven by an `httptest` UCP server returning 500 on `/planes/radius/local/providers`. - `ComputeGraphResponse` `listAllResourcesByApplication` error path (lines 62-63), driven by an `httptest` server returning a resource type then failing on `GetProviderSummary`. - `ComputeGraphResponse` `listAllResourcesByEnvironment` error path (lines 67-68), driven by an `httptest` server where application-scoped listing succeeds but environment-scoped listing returns 500. - Database error path through `GetGraph.Run` and `GetGraphv20250801preview.Run` (non-`NotFound` `Get` error is propagated). - End-to-end success path through both `Run` methods into `ComputeGraphResponse`, driven by an `httptest` UCP server returning an empty providers list to yield an empty graph. Coverage on the new shared helper rose from 0% to ~87.5%, both `Run` methods are at 100%, and the `v20250801preview` getGraph package is at 100%. ```go Custom: map[string]builder.Operation[datamodel.Application_v20250801preview]{ "getGraph": { APIController: func(opt apictrl.Options) (apictrl.Controller, error) { return app_v20250801_ctrl.NewGetGraphv20250801preview(opt, *recipeControllerConfig.UCPConnection) }, }, }, ``` ## Type of change - This pull request fixes a bug in Radius and has an approved issue (issue link required). ## Contributor checklist Please verify that the PR meets the following requirements, where applicable: - An overview of proposed schema changes is included in a linked GitHub issue. - [ ] Yes - [x] Not applicable - A design document is added or updated under `eng/design-notes/` in this repository, if new APIs are being introduced. - [ ] Yes - [x] Not applicable - The design document has been reviewed and approved by Radius maintainers/approvers. - [ ] Yes - [x] Not applicable - A PR for [resource-types-contrib](https://github.com/radius-project/resource-types-contrib/) is created, if resource types or recipes are affected by the changes in this PR. - [ ] Yes - [x] Not applicable - A PR for [dashboard](https://github.com/radius-project/dashboard/) is created, if the Radius Dashboard is affected by the changes in this PR. - [ ] Yes - [x] Not applicable - A PR for the [documentation repository](https://github.com/radius-project/docs) is created, if the changes in this PR affect the documentation or any user facing updates are made. - [ ] Yes - [x] Not applicable --------- Signed-off-by: Will <28876888+willtsai@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: willtsai <28876888+willtsai@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Reshma Abdul Rahim <reshmarahim.abdul@microsoft.com>

Description
POST .../providers/Radius.Core/applications/{app}/getGraphreturned 404 because the namespace builder forRadius.Corenever wired thegetGraphcustom action — onlyApplications.Core/applicationsdid. The OpenAPI route exists but had no controller, blocking app graph rendering in the dashboard.New controller:
GetGraphv20250801previewinpkg/corerp/frontend/controller/applications/v20250801preview/getgraph.go(packagev20250801preview). Placed in av20250801preview/subpackage to match the convention established bypkg/corerp/frontend/controller/environments/v20250801preview/. Typed againstdatamodel.Application_v20250801previewand uses theApplication20250801*converters.Shared helper: Extracted a
ComputeGraphResponseexported helper in the parentpkg/corerp/frontend/controller/applicationspackage so both theApplications.CoreandRadius.CoregetGraph controllers reuse the same graph-listing logic (resource type discovery, application-/environment-scoped listing, and graph computation) without duplication.Stricter validation:
ComputeGraphResponseusesresources.ParseResource(instead ofresources.Parse) to validate the environment ID is a named resource, rejecting collection or custom-action IDs. The error is wrapped withfmt.Errorffor context.Wiring:
SetupRadiusCoreNamespaceinpkg/corerp/setup/setup.gonow registersCustom["getGraph"]on theapplicationsresource, analogous to theApplications.Core/applicationsregistration.Tests: Unit test for the not-found path on the new controller, plus a router assertion in
setup_test.gothatPOST .../radius.core/applications/app0/getgraphresolves toACTIONGETGRAPH. Additional tests targeting the lines flagged by Codecov:ComputeGraphResponseinvalid-environment-ID error path.ComputeGraphResponseUCP error-propagation path, driven by anhttptestUCP server returning 500 on/planes/radius/local/providers.ComputeGraphResponselistAllResourcesByApplicationerror path (lines 62-63), driven by anhttptestserver returning a resource type then failing onGetProviderSummary.ComputeGraphResponselistAllResourcesByEnvironmenterror path (lines 67-68), driven by anhttptestserver where application-scoped listing succeeds but environment-scoped listing returns 500.GetGraph.RunandGetGraphv20250801preview.Run(non-NotFoundGeterror is propagated).Runmethods intoComputeGraphResponse, driven by anhttptestUCP server returning an empty providers list to yield an empty graph.Coverage on the new shared helper rose from 0% to ~87.5%, both
Runmethods are at 100%, and thev20250801previewgetGraph package is at 100%.Type of change
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
eng/design-notes/in this repository, if new APIs are being introduced.