Increase path field max size and improve telemetry errors#431
Increase path field max size and improve telemetry errors#431
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
WalkthroughThe pull request refactors error logging to extract nested exception details and adds a summary parameter to telemetry tracking. It also applies database column length constraints (512 characters) to file path fields across plugin model classes and introduces unit tests for telemetry data sanitization. Changes
Sequence Diagram(s)sequenceDiagram
participant TaskRunner as TaskRunner
participant TBC as TaskBarController
participant TS as TelemetryService
participant Telemetry as Telemetry Backend
TaskRunner->>TaskRunner: Task execution fails<br/>catch exception
TaskRunner->>TaskRunner: Extract most specific<br/>cause via NestedExceptionUtils
TaskRunner->>TBC: setErrorLog(task, title, content, summary)
TBC->>TBC: Update UI & show error dialog
TBC->>TS: Prepare telemetry payload<br/>with summary field
TS->>TS: sanitize(params, maxLength)<br/>Redact paths & truncate
TS->>Telemetry: Send sanitized payload
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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)
owlplug-client/src/main/java/com/owlplug/core/services/TelemetryService.java (1)
113-125: Truncation before redaction may leave partial paths unredacted.The current order truncates the value first (lines 116-118), then applies path redaction (line 121). If a path spans the truncation boundary, it may be cut in a way that no longer matches the redaction regex, potentially leaking partial sensitive paths.
Also, if
entry.getValue()returnsnull,value.length()on line 116 will throw aNullPointerException.Consider:
- Applying redaction before truncation, or
- Adding a null check for the value
Proposed fix
void sanitize(Map<String, String> params, int maxLength) { for (Map.Entry<String, String> entry : params.entrySet()) { String value = entry.getValue(); + if (value == null) { + continue; + } + + // Redact absolute paths first (Unix & Windows) + value = value.replaceAll("([A-Za-z]:\\\\\\\\[^\\s]+)|(/[^\\s]+)", "<path>"); + if (value.length() > maxLength) { value = value.substring(0, maxLength) + "…"; } - - // Redact absolute paths (Unix & Windows) - value = value.replaceAll("([A-Za-z]:\\\\\\\\[^\\s]+)|(/[^\\s]+)", "<path>"); entry.setValue(value); - } }
🤖 Fix all issues with AI agents
In `@owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java`:
- Around line 118-120: In TaskRunner replace the direct call to
NestedExceptionUtils.getMostSpecificCause(ex).getMessage() with a null-safe
extraction: retrieve the most specific cause via
NestedExceptionUtils.getMostSpecificCause(ex), check if that cause is null or
cause.getMessage() is null, and use a safe fallback (e.g., empty string or
cause.getClass().getSimpleName()) for the summary; update the code paths that
build the summary (the block calling StringUtils.getStackTraceAsString(ex) and
NestedExceptionUtils.getMostSpecificCause(ex).getMessage()) to use this
null-safe message.
🧹 Nitpick comments (1)
owlplug-client/src/test/java/com/owlplug/core/services/TelemetryServiceTest.java (1)
8-10: Test instantiation bypasses Spring context.
TelemetryServiceis a Spring@Servicewith@PostConstructinitialization and autowired dependencies. Directly instantiating it vianew TelemetryService()works for the currentsanitize()tests because that method doesn't rely on injected fields, but this approach is fragile if the implementation changes.Consider adding a test for null values in the map to align with the null-safety concern in
sanitize():Suggested additional test case
`@Test` public void testShouldHandleNullValues() { Map<String, String> params = new HashMap<>(); params.put("key", null); telemetryService.sanitize(params); // Verify no exception and value unchanged or handled gracefully }
owlplug-client/src/main/java/com/owlplug/core/components/TaskRunner.java
Show resolved
Hide resolved
71e230f to
0b393fe
Compare
No description provided.