Repository navigation
Cus-11200 added support to decode strings with urls - #356
Conversation
📝 WalkthroughWalkthroughThis PR updates the base64_converter addon with a version bump to 1.0.3, adds the Apache Commons Lang 3 dependency, updates annotation documentation text, and enhances the decode functionality with URL-safe Base64 detection and fallback logic. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
base64_converter/src/main/java/com/testsigma/addons/generators/DecodeStringToBase64.java (1)
27-33: Specify charset when constructing String from bytes.Using
new String(byte[])relies on the platform's default charset, which can vary across systems and lead to inconsistent behavior. Explicitly specifyStandardCharsets.UTF_8for predictable results.♻️ Proposed fix
Add import:
import java.nio.charset.StandardCharsets;Then update the String constructors:
- decodedString = new String(Base64.getUrlDecoder().decode(input)); + decodedString = new String(Base64.getUrlDecoder().decode(input), StandardCharsets.UTF_8);- decodedString = new String(Base64.getDecoder().decode(input)); + decodedString = new String(Base64.getDecoder().decode(input), StandardCharsets.UTF_8);- decodedString = new String(Base64.getUrlDecoder().decode(input)); + decodedString = new String(Base64.getUrlDecoder().decode(input), StandardCharsets.UTF_8);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@base64_converter/src/main/java/com/testsigma/addons/generators/DecodeStringToBase64.java` around lines 27 - 33, In DecodeStringToBase64 update the places where decodedString is constructed from decoded bytes to specify the charset: replace new String(Base64.getUrlDecoder().decode(input)) and new String(Base64.getDecoder().decode(input)) with new String(..., StandardCharsets.UTF_8); add the import for java.nio.charset.StandardCharsets so both the normal and fallback (URL-safe) decoding branches use UTF-8 explicitly.base64_converter/src/main/java/com/testsigma/addons/generators/Base64Converter.java (1)
22-22: Consider specifying charset for consistency.While not changed in this PR,
getBytes()without a charset argument uses platform default encoding. For consistency with the recommended changes inDecodeStringToBase64, consider usingStandardCharsets.UTF_8:String base64String = Base64.getEncoder().encodeToString(string.getValue().toString().getBytes(StandardCharsets.UTF_8));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@base64_converter/src/main/java/com/testsigma/addons/generators/Base64Converter.java` at line 22, The Base64 conversion uses string.getValue().toString().getBytes() without a charset which relies on platform default; update the encode call in Base64Converter (the line creating base64String) to pass StandardCharsets.UTF_8 to getBytes and add the corresponding import for java.nio.charset.StandardCharsets so the Base64.getEncoder().encodeToString(...) consistently uses UTF-8.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@base64_converter/src/main/java/com/testsigma/addons/generators/DecodeStringToBase64.java`:
- Around line 10-11: Update the `@TestDataFunction` annotation on the
DecodeStringToBase64 class/function: change displayName to "Decode the base64
input string" and change description to "Decodes a base64 encoded string to
plain text" so the annotation accurately reflects that the function decodes from
Base64 to a plain string (refer to the
`@com.testsigma.sdk.annotation.TestDataFunction` on DecodeStringToBase64).
---
Nitpick comments:
In
`@base64_converter/src/main/java/com/testsigma/addons/generators/Base64Converter.java`:
- Line 22: The Base64 conversion uses string.getValue().toString().getBytes()
without a charset which relies on platform default; update the encode call in
Base64Converter (the line creating base64String) to pass StandardCharsets.UTF_8
to getBytes and add the corresponding import for
java.nio.charset.StandardCharsets so the Base64.getEncoder().encodeToString(...)
consistently uses UTF-8.
In
`@base64_converter/src/main/java/com/testsigma/addons/generators/DecodeStringToBase64.java`:
- Around line 27-33: In DecodeStringToBase64 update the places where
decodedString is constructed from decoded bytes to specify the charset: replace
new String(Base64.getUrlDecoder().decode(input)) and new
String(Base64.getDecoder().decode(input)) with new String(...,
StandardCharsets.UTF_8); add the import for java.nio.charset.StandardCharsets so
both the normal and fallback (URL-safe) decoding branches use UTF-8 explicitly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1563987e-2e0e-4187-8b42-223b90beea11
📒 Files selected for processing (3)
base64_converter/pom.xmlbase64_converter/src/main/java/com/testsigma/addons/generators/Base64Converter.javabase64_converter/src/main/java/com/testsigma/addons/generators/DecodeStringToBase64.java
| @com.testsigma.sdk.annotation.TestDataFunction(displayName = "Decode the input string to base64", | ||
| description = "Decodes the input string to base64") |
There was a problem hiding this comment.
Incorrect terminology in annotation text.
The displayName and description say "Decode the input string to base64", but this function decodes from Base64 to a plain string. Consider updating to:
- displayName:
"Decode the base64 input string" - description:
"Decodes a base64 encoded string to plain text"
📝 Proposed fix
-@com.testsigma.sdk.annotation.TestDataFunction(displayName = "Decode the input string to base64",
- description = "Decodes the input string to base64")
+@com.testsigma.sdk.annotation.TestDataFunction(displayName = "Decode the base64 input string",
+ description = "Decodes a base64 encoded string to plain text")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @com.testsigma.sdk.annotation.TestDataFunction(displayName = "Decode the input string to base64", | |
| description = "Decodes the input string to base64") | |
| `@com.testsigma.sdk.annotation.TestDataFunction`(displayName = "Decode the base64 input string", | |
| description = "Decodes a base64 encoded string to plain text") |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@base64_converter/src/main/java/com/testsigma/addons/generators/DecodeStringToBase64.java`
around lines 10 - 11, Update the `@TestDataFunction` annotation on the
DecodeStringToBase64 class/function: change displayName to "Decode the base64
input string" and change description to "Decodes a base64 encoded string to
plain text" so the annotation accurately reflects that the function decodes from
Base64 to a plain string (refer to the
`@com.testsigma.sdk.annotation.TestDataFunction` on DecodeStringToBase64).
please review this addon and publish as PUBLIC
Addon name : base64_converter
Addon accont: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira: https://testsigma.atlassian.net/browse/CUS-11200
fix
added support to detect and decode "URL-safe Base64 encoding"
Summary by CodeRabbit
Release Notes
New Features
Improvements
Chores