Gracefully handle SCANOSS errors and hide KB completed message#299
Conversation
Signed-off-by: Park Wonjae <wonjae.park@lge.com>
📝 WalkthroughWalkthroughChangesSCANOSS and report updates
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant run_scanoss_py
participant Scanner
participant SCANOSS_API
participant Report
CLI->>run_scanoss_py: invoke with named scan options
run_scanoss_py->>SCANOSS_API: send dummy WFP connectivity check
SCANOSS_API-->>run_scanoss_py: return API status
run_scanoss_py->>Scanner: execute scan with captured output
Scanner-->>run_scanoss_py: return output or failure indicators
run_scanoss_py->>Report: return parsed results and skipped flag
Report-->>CLI: preserve KB cover-comment status
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Signed-off-by: Park Wonjae <wonjae.park@lge.com>
Signed-off-by: Park Wonjae <wonjae.park@lge.com>
cdac8c1 to
b25c578
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tests/cli_test.py (1)
29-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valuePrefix the unused variable
api_limit_exceedwith an underscore.The
api_limit_exceedvariable unpacked fromrun_scanoss_pyis not used within the test. Prefixing it with an underscore signals that this is intentional and resolves the static analysis warning.♻️ Proposed fix
- ret_scanoss, api_limit_exceed = run_scanoss_py( + ret_scanoss, _api_limit_exceed = run_scanoss_py( path_to_find_bin, output_path=fosslight_report_name, format=[],🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/cli_test.py` around lines 29 - 36, Rename the unused second return-value variable in the run_scanoss_py call within the test to _api_limit_exceed, preserving the existing unpacking and behavior while resolving the static-analysis warning.Source: Linters/SAST tools
src/fosslight_source/run_scanoss.py (1)
62-62: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueClose the
StringIObuffer to free up memory.Although
io.StringIObuffers are memory-backed and will eventually be garbage collected, it is a good practice to explicitly close them when they are no longer needed.♻️ Proposed fix
Apply the following change after you have extracted the buffer's value at line 81:
captured_output = output_buffer.getvalue() + output_buffer.close() if captured_output:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/fosslight_source/run_scanoss.py` at line 62, Close the output_buffer StringIO after extracting its value in run_scanoss, ensuring all reads from the buffer occur before closing it and preserving the existing output behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fosslight_source/run_scanoss.py`:
- Around line 78-81: Update the exception handling around
Scanner.scan_folder_with_options() to retain the exception message in the output
used by subsequent API-limit and timeout pattern matching. Append or otherwise
check the caught error alongside output_buffer content before the existing
detection logic runs, while preserving the current debug logging.
---
Nitpick comments:
In `@src/fosslight_source/run_scanoss.py`:
- Line 62: Close the output_buffer StringIO after extracting its value in
run_scanoss, ensuring all reads from the buffer occur before closing it and
preserving the existing output behavior.
In `@tests/cli_test.py`:
- Around line 29-36: Rename the unused second return-value variable in the
run_scanoss_py call within the test to _api_limit_exceed, preserving the
existing unpacking and behavior while resolving the static-analysis warning.
🪄 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: b85d8752-1425-447c-a4ad-7e058484f796
📒 Files selected for processing (3)
src/fosslight_source/cli.pysrc/fosslight_source/run_scanoss.pytests/cli_test.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fosslight_source/run_scanoss.py`:
- Around line 81-86: Use the caller-provided timeout in the preflight
session.post call within run_scanoss_py instead of the hardcoded five-second
value, and keep the generated copy synchronized by applying the same change in
src/fosslight_source/run_scanoss.py lines 81-86 and
build/lib/fosslight_source/run_scanoss.py lines 81-86.
🪄 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: 1ac285cd-f7f0-4b99-bb7e-4bd978de6d13
📒 Files selected for processing (2)
build/lib/fosslight_source/run_scanoss.pysrc/fosslight_source/run_scanoss.py
Check API availability and rate limit status by sending a dummy WFP POST request before starting the full scan. This avoids wasting time generating fingerprints when the SCANOSS API is unreachable or rate-limited. Signed-off-by: Park Wonjae <wonjae.park@lge.com>
e4773e0 to
4051831
Compare
| if os.path.exists(output_json_file): | ||
| os.remove(output_json_file) | ||
|
|
||
| output_buffer = io.StringIO() |
There was a problem hiding this comment.
@JustinWonjaePark , 추후 output_buffer.close() 권장드립니다.
Key Changes
retry=0to prevent unnecessary wait times from internal retries.try-exceptblocks to gracefully log errors/warnings without interrupting the overall execution flow.run_scanoss_pyintests/cli_test.py.KB(...) : Completedto the Cover sheet comments when KB scan completes successfully, while keeping other failure status messages.