Repository navigation
XRAY-171808 - Support waiver request flow in npm debug report jf ca flow - #955
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
53233cb to
24622fd
Compare
| } | ||
| } | ||
| // "all" is excluded: with nothing selectable it must not re-prompt forever. | ||
| if npmLog && requestedRows != "all" && len(selected) == 0 { |
There was a problem hiding this comment.
The npmLog flag only covers part of the reversed-range problem, and the root cause is still in getSelectedPackages (the range loop for i := startRow; i <= endRow never runs when start > end). I ran a few inputs through selectWaiverPackages:
3-1: npm-log reports are rejected with "No rows were selected." Regular reports return ok with nothing selected. After the user types a reason,requestWaiverreturns without sending anything or saying so.1,3-1(and2-1,3): accepted on both report kinds. The reversed part is dropped silently and only the other rows are requested.
Rejecting start > end in getSelectedPackages covers both cases and also lets you drop the npmLog parameter and the requestedRows != "all" guard:
if startRow > endRow {
log.Error(fmt.Sprintf("Invalid range: %d-%d. The first row must not be after the last row.", startRow, endRow))
return nil, false
}(placed right after the two Atoi calls in the range branch). getSelectedPackages has a single non-test caller, so the change is contained. The test case "other reports keep accepting a reversed range" in Test_selectWaiverPackages_emptySelection pins the old behaviour and would need to flip. This test fails today and passes with the change above:
func TestReversedRangeIsRejectedForEveryReport(t *testing.T) {
rows := []*PackageStatus{
{PackageName: "a", PackageVersion: "1.0.0", WaiverAllowed: true, BlockedPackageUrl: "u1"},
{PackageName: "b", PackageVersion: "1.0.0", WaiverAllowed: true, BlockedPackageUrl: "u2"},
{PackageName: "c", PackageVersion: "1.0.0", WaiverAllowed: true, BlockedPackageUrl: "u3"},
}
for _, in := range []string{"3-1", "1,3-1"} {
_, ok := getSelectedPackages(in, rows)
assert.False(t, ok, "getSelectedPackages(%q)", in)
}
}Review generated by xray-pr-review
| if shouldOfferWaiver(packagesStatus, utils.IsCI()) { | ||
| err = errors.Join(ca.requestWaiver(packagesStatus)) |
There was a problem hiding this comment.
The previous head (9bbb460) had err = errors.Join(err, ca.requestWaiver(packagesStatus)) a few lines below this one. The current head has err = errors.Join(ca.requestWaiver(packagesStatus)), which is the same as dev, so this PR no longer changes how Run() handles errors. Item 4 of the description ("Run() now accumulates errors with errors.Join instead of overwriting them") is no longer true.
With the single-argument form, whenever the waiver prompt is shown (non-CI, at least one eligible row) the err accumulated so far is overwritten, including errors from doCurateAudit, Progress().Quit(), printResult and an earlier project's waiver. If the waiver returns nil, Run() returns nil even though the "encountered errors" banner was already printed. For example, with --working-dirs where one directory fails and another has a waivable row, the command exits 0. It is interactive-only and the same on dev, so I'd rate it low, but npm-log reports can now reach this path.
Was the revert intentional? If not, restoring the accumulator is a one-line fix:
| if shouldOfferWaiver(packagesStatus, utils.IsCI()) { | |
| err = errors.Join(ca.requestWaiver(packagesStatus)) | |
| if shouldOfferWaiver(packagesStatus, utils.IsCI()) { | |
| err = errors.Join(err, ca.requestWaiver(packagesStatus)) |
Otherwise please update item 4 of the description. (Not covered by a test: Run() reads stdin and has no seam.)
Review generated by xray-pr-review
24622fd to
34d9a86
Compare

…r in npm debug jf ca flow
devbranch.Description: When
npm installfails duringjf ca, the report is rebuilt from npm's debug log and flagged partial. The waiver loop skipped partial reports, so customers never saw the waiver prompt.Changes (npm debug-log report only):
BlockedPackageUrlandWaiverAllowedare offered. "All versions blocked" and unresolved-range rows are never offered or sent.allselects only the offered rows.3-1or1,3-1is rejected, so the prompt repeats. Regular reports are unchanged and still accept reversed ranges.Run()keeps the existing waiver error handling, so this PR doesn't change how it accumulates errors.Before
After
Screen.Recording.2026-11-23.at.9.53.47.AM.mov