Skip to content

Ignore empty SBOM source entries when mapping files#185

Merged
bjk7119 merged 4 commits into
mainfrom
develop
Apr 30, 2026
Merged

Ignore empty SBOM source entries when mapping files#185
bjk7119 merged 4 commits into
mainfrom
develop

Conversation

@bjk7119

@bjk7119 bjk7119 commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Fixed handling of empty or blank source paths so no invalid results or paths are produced.
    • Ignored empty/invalid pattern values during file extraction to avoid spurious matches.
  • Chores

    • Suppressed noisy output from external license download tooling for cleaner runs.
    • Simplified license creation logging to report only the destination path.

@bjk7119 bjk7119 requested a review from dd-jy April 29, 2026 01:48
@bjk7119 bjk7119 self-assigned this Apr 29, 2026
@bjk7119 bjk7119 added the chore [PR/Issue] Refactoring, maintenance the code label Apr 29, 2026
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@bjk7119 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 34 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34ae8333-afee-4bff-beba-071adc8f81a3

📥 Commits

Reviewing files that changed from the base of the PR and between b9c3282 and 6c5e6d1.

📒 Files selected for processing (1)
  • src/fosslight_prechecker/_download_lic.py
📝 Walkthrough

Walkthrough

Refined YAML path extraction to ignore empty/blank source names; changed license download to suppress external tool stdout/stderr by redirecting output to devnull and added fallback call signatures when invoking reuse_download.

Changes

Cohort / File(s) Summary
YAML path handling
src/fosslight_prechecker/_result.py
get_path_in_yaml now returns an empty list for None or whitespace-only source_name_or_path; non-empty inputs continue to be joined/normalized. extract_files_in_path skips falsy remove_pattern values during iteration.
License download / output suppression
src/fosslight_prechecker/_download_lic.py
download_lic_text_file redirects stdout/stderr to /dev/null and attempts to pass a devnull writer to reuse_download via out=; if that fails it retries with a positional devnull, then falls back to calling reuse_download normally. Adjusted logging in copy_to_root to report destination path only.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as download_lic_text_file
  participant Reuse as reuse_download (external)
  participant DevNull as /dev/null (os)
  Caller->>DevNull: open devnull (write)
  Caller->>Reuse: call reuse_download(out=devnull, ...)
  alt if TypeError / unsupported kw
    Caller->>Reuse: call reuse_download(devnull, ...)
    alt if still fails
      Caller->>Reuse: call reuse_download(... without devnull)
    end
  end
  Reuse-->>Caller: returns result or raises
  Caller->>Caller: log destination (no source->LICENSE arrow)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title specifically addresses ignoring empty SBOM source entries, which directly aligns with the main changes in _result.py that prevent YAML paths from being generated with empty filenames.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch develop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 22 minutes and 34 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/fosslight_prechecker/_download_lic.py (1)

87-111: ⚠️ Potential issue | 🔴 Critical

Fix uninitialized fallback flag and success return logic.

success_from_lge is used at Line 111 but is not guaranteed to be assigned. Also, reuse_return_code == 0 and success_from_lge can incorrectly return False even when reuse download succeeds.

Proposed fix
 def download_lic_text_file(parsed_args: str, prj: Project, download_path: str, input_license: list) -> None:
     # 0: successfully downloaded, 1: failed to download
     # suppress direct prints by passing a devnull writer to reuse, and python-level redirection
     reuse_return_code = None
+    success_from_lge = False
@@
-    return reuse_return_code == 0 and success_from_lge
+    return reuse_return_code == 0 or success_from_lge
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/fosslight_prechecker/_download_lic.py` around lines 87 - 111, The code
uses success_from_lge without initialization and returns reuse_return_code == 0
and success_from_lge which can be wrong; initialize success_from_lge = False
before the license loop, set success_from_lge = True when
lge_lic_download(download_path, lic) succeeds (inside the for lic in
input_license loop), and change the final return to return reuse_return_code ==
0 or success_from_lge so the function returns True if either the reuse_download
succeeded or any lge_lic_download succeeded; keep existing calls to
reuse_download, present_license_file, and lge_lic_download and preserve the
current warning log behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/fosslight_prechecker/_download_lic.py`:
- Around line 94-100: The fallback calls to reuse_download currently swallow all
Exceptions (in the inner except and outer except) which hides real errors;
change both exception handlers to only catch TypeError (signature mismatch) and
let any other exception propagate—i.e., when calling reuse_download(parsed_args,
prj, devnull_py) catch only TypeError and then call reuse_download(parsed_args,
prj), and in the outer handler catch only TypeError as well (re-raise or allow
other exceptions to bubble up). Ensure references: reuse_download, parsed_args,
prj, devnull_py.

---

Outside diff comments:
In `@src/fosslight_prechecker/_download_lic.py`:
- Around line 87-111: The code uses success_from_lge without initialization and
returns reuse_return_code == 0 and success_from_lge which can be wrong;
initialize success_from_lge = False before the license loop, set
success_from_lge = True when lge_lic_download(download_path, lic) succeeds
(inside the for lic in input_license loop), and change the final return to
return reuse_return_code == 0 or success_from_lge so the function returns True
if either the reuse_download succeeded or any lge_lic_download succeeded; keep
existing calls to reuse_download, present_license_file, and lge_lic_download and
preserve the current warning log behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f4cfc340-cfe4-4b26-9a56-1942098d245c

📥 Commits

Reviewing files that changed from the base of the PR and between ede9531 and b9c3282.

📒 Files selected for processing (2)
  • src/fosslight_prechecker/_download_lic.py
  • src/fosslight_prechecker/_result.py
✅ Files skipped from review due to trivial changes (1)
  • src/fosslight_prechecker/_result.py

Comment thread src/fosslight_prechecker/_download_lic.py Outdated
@bjk7119 bjk7119 merged commit 5146bca into main Apr 30, 2026
6 checks passed
@bjk7119 bjk7119 added bug fix [PR] Fix the bug and removed chore [PR/Issue] Refactoring, maintenance the code labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix [PR] Fix the bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants