Repository navigation
XRAY-171808 - Support waiver request flow and improve npm debug parse… - #955
gauriy-tech wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
…r in npm debug jf ca flow
413b877 to
9bbb460
Compare
| return nil, false | ||
| } | ||
| } | ||
| return selected, true |
There was a problem hiding this comment.
A reversed range such as 3-1 selects nothing but is still treated as valid: the user is then asked for a reason, and requestWaiver returns without sending anything or saying so. The root cause is in getSelectedPackages (the range loop for i := startRow; i <= endRow is empty), so regular reports behave the same way today; this PR just makes the npm-log path inherit it. Consider rejecting an empty selection here so the prompt repeats instead:
| return selected, true | |
| if len(selected) == 0 { | |
| log.Error("No rows were selected.") | |
| return nil, false | |
| } | |
| return selected, true |
Review generated by xray-pr-review
| if report.npmLogPartial { | ||
| return isNpmLogWaivable | ||
| } | ||
| return func(*PackageStatus) bool { return true } |
There was a problem hiding this comment.
Question: was keeping every row selectable for regular reports intentional, while npm debug-log reports are now limited to waivable rows? For a regular report all still includes rows with WaiverAllowed == false (they come back as a "forbidden" row in the result table, so this works today), which means jf ca offers different rows depending on whether npm install succeeded. If that is a deliberate scope limit, a one-line comment here would help; otherwise a follow-up could apply the same predicate to every report type.
Review generated by xray-pr-review
| } | ||
| for _, name := range []string{"curl", "vitest"} { | ||
| require.NotNil(t, byName[name], name) | ||
| assert.NotEmpty(t, byName[name].BlockedPackageUrl, name) |
There was a problem hiding this comment.
This asserts the tarball URL but not the version. isNpmLogWaivable only rejects the all-versions marker, so a row with a URL but a wrong or blank PackageVersion would still pass. Consider also asserting the version, since the vitest@ log line carries no version and it is resolved from want: 5.1.0:
| assert.NotEmpty(t, byName[name].BlockedPackageUrl, name) | |
| assert.NotEmpty(t, byName[name].BlockedPackageUrl, name) | |
| assert.Equal(t, map[string]string{"curl": "0.1.2", "vitest": "5.1.0"}[name], byName[name].PackageVersion, name) |
Review generated by xray-pr-review
| } | ||
| // If at least one row allows a waiver request, ask the user whether to request one. | ||
| if shouldOfferWaiver(packagesStatus, utils.IsCI()) { | ||
| err = errors.Join(err, ca.requestWaiver(packagesStatus)) |
There was a problem hiding this comment.
FYI: this errors.Join(err, ...) change (item 4 in the description) is not covered by the new tests. Reverting it to the old err = errors.Join(ca.requestWaiver(...)) leaves all four new test groups green (I tried it). Covering it would need a seam around requestWaiver, since it reads stdin, so this is a note rather than a request. It also means jf ca can now exit non-zero where it previously exited 0, when an earlier scan or print error was accumulated and the waiver prompt ran. That looks like the right behaviour; worth mentioning in the release note.
Review generated by xray-pr-review
…r in npm debug jf ca flow
devbranch.Description: When npm install fails during jf ca, the report is rebuilt from npm's debug log and flagged partial, so the waiver loop skipped it and customers never saw the prompt.
Before
After
Screen.Recording.2026-11-23.at.9.53.47.AM.mov