fix(robot): handle empty permissions in robot view#998
Conversation
Fixes goharbor#997 Signed-off-by: Jay2006sawant <jay242902@gmail.com>
|
@Vad1mo Can you please look into this? |
NucleoFusion
left a comment
There was a problem hiding this comment.
I dont think so we can create robots with 0 permissions. (I confirmed you cant)
But i think the gaurd is not a bad to have.
@qcserestipy what do you think? Should we have it or is it redundant?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #998 +/- ##
=========================================
- Coverage 10.99% 9.19% -1.80%
=========================================
Files 173 321 +148
Lines 8671 16088 +7417
=========================================
+ Hits 953 1480 +527
- Misses 7612 14474 +6862
- Partials 106 134 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@NucleoFusion I think we could get this into the code. I would be curious to know how this issue was found if the cli and ui both do not allow to create robots with 0 permissions in practice @Jay2006sawant. |
Description
harbor robot viewpanics when the Harbor API returns a robot with an empty or nilpermissionsarray. The view indexedrobot.Permissions[0]unconditionally, whileharbor robot listalready guarded this case.This PR adds safe fallbacks for the permission count and project namespace header, matching the list view behavior.
Type of Change
Changes
robotPermissionSummaryhelper to safely read permission count and namespace0,--) when permission details are missingTest plan
go test ./pkg/views/robot/view/... -vrobotPermissionSummaryreturns safe defaults for nil/empty permissions (no index panic)