Skip to content

XRAY-171808 - Support waiver request flow and improve npm debug parse… - #955

Open
gauriy-tech wants to merge 2 commits into
jfrog:devfrom
gauriy-tech:feature/XRAY-171808-supt-npm-wav-req
Open

gauriy-tech wants to merge 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, so the waiver loop skipped it and customers never saw the prompt.

  1. Let npmLogPartial reports reach the waiver prompt. The CVS fallback for pip and other tools is unchanged.
  2. Offer only rows that have a BlockedPackageUrl and WaiverAllowed. "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. Run() now accumulates errors with errors.Join instead of overwriting them, as the sibling statements already do.
  5. Tests cover a mix of waivable and non-waivable rows.

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: c138ea69-cfd5-4f1a-a5fc-88df0f07c3bf

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
return nil, false
}
}
return selected, true

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.

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:

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

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.

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)

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.

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:

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

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.

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

This branch is waiting to be deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants