Skip to content

XRAY-171808 - Support waiver request flow in npm debug report jf ca flow - #955

Merged
attiasas merged 2 commits into
jfrog:devfrom
gauriy-tech:feature/XRAY-171808-supt-npm-wav-req
Nov 25, 2026
Merged

attiasas merged 2 commits into
jfrog:devfrom
gauriy-tech:feature/XRAY-171808-supt-npm-wav-req

Conversation

@gauriy-tech

@gauriy-tech gauriy-tech commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

…r in npm debug jf ca flow


Description: When npm install fails during jf 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):

  1. Partial reports from the npm debug-log fallback reach the waiver prompt. The CVS fallback for pip and other tools is unchanged.
  2. Only rows with a BlockedPackageUrl and WaiverAllowed are offered. "All versions blocked" and unresolved-range rows are never offered or sent.
  3. Row numbers in the prompt match the table, and all selects only the offered rows.
  4. On npm debug-log reports, a reversed row range such as 3-1 or 1,3-1 is rejected, so the prompt repeats. Regular reports are unchanged and still accept reversed ranges.
  5. Tests cover a mix of waivable and non-waivable rows, the version and URL of waivable rows, and reversed ranges on both report types.

Run() keeps the existing waiver error handling, so this PR doesn't change how it accumulates errors.

Before

Screenshot 2026-11-23 at 9 49 15 AM

After

Screenshot 2026-11-23 at 9 52 17 AM Screenshot 2026-11-23 at 9 53 08 AM
Screen.Recording.2026-11-23.at.9.53.47.AM.mov
Screenshot 2026-11-23 at 9 55 24 AM

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization, Workspace
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: c021361c-fc4a-44da-b9c7-963f28c17ae4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@gauriy-tech
gauriy-tech force-pushed the feature/XRAY-171808-supt-npm-wav-req branch from 413b877 to 9bbb460 Compare November 23, 2026 10:28
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 23, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 23, 2026
Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/curation/curationaudit_test.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
@gauriy-tech
gauriy-tech force-pushed the feature/XRAY-171808-supt-npm-wav-req branch from 53233cb to 24622fd Compare November 24, 2026 17:39
@gauriy-tech gauriy-tech added the safe to test Approve running integration tests on a pull request label Nov 24, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@gauriy-tech gauriy-tech changed the title XRAY-171808 - Support waiver request flow and improve npm debug parse… XRAY-171808 - Support waiver request flow in npm debug report jf ca flow Nov 24, 2026
Comment thread commands/curation/curationaudit.go Outdated
}
}
// "all" is excluded: with nothing selectable it must not re-prompt forever.
if npmLog && requestedRows != "all" && len(selected) == 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, requestWaiver returns without sending anything or saying so.
  • 1,3-1 (and 2-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

Comment on lines +561 to +562
if shouldOfferWaiver(packagesStatus, utils.IsCI()) {
err = errors.Join(ca.requestWaiver(packagesStatus))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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

@gauriy-tech
gauriy-tech force-pushed the feature/XRAY-171808-supt-npm-wav-req branch from 24622fd to 34d9a86 Compare November 25, 2026 05:04
@attiasas attiasas added improvement Automatically generated release notes safe to test Approve running integration tests on a pull request labels Nov 25, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Nov 25, 2026

@attiasas attiasas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@attiasas
attiasas merged commit 1b5f893 into jfrog:dev Nov 25, 2026
74 of 78 checks passed

This branch is waiting to be deployed

1 waiting deployment
frogbot — 34d9a867 Waiting Nov 25, 2026 by gauriy-tech via scan-pull-request #4866
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants