Skip to content

[TODO/ENHC]: Error handling in TestController.java implemented validation - #1908

Merged
lbroudoux merged 5 commits into
microcks:1.13.xfrom
PranjaliBhardwaj:error-handling-fix-clean
Feb 4, 2026
Merged

lbroudoux merged 5 commits into
microcks:1.13.xfrom
PranjaliBhardwaj:error-handling-fix-clean

Conversation

@PranjaliBhardwaj

Copy link
Copy Markdown
Contributor

[ENHANCEMENT]
issue: #1895

Description
Added validation: If a secret name is provided but not found in the repository, the method now returns an error instead of continuing with null.
Clear error message: Returns HTTP 400 (BAD_REQUEST) with: "Secret '{secretName}' not found. Please ensure the secret exists before creating the test."
Logging: Added a warning log when a secret is specified but not found for debugging.
Removed TODO: The TODO comment is resolved by implementing the validation.

The implementation:
Validates that if a secret name is provided, it must exist
Returns a clear, actionable error message
Uses appropriate HTTP status code (400 BAD_REQUEST)
Follows existing error handling patterns in the codebase
When a test request includes a secret name that doesn't exist, the API will return a clear error instead of silently proceeding.

Signed-off-by: Pranjali Bhardwaj <[email protected]>
@PranjaliBhardwaj

Copy link
Copy Markdown
Contributor Author

@lbroudoux new pr created, i closed old ones with changes

@lbroudoux
lbroudoux changed the base branch from master to 1.13.x January 15, 2026 14:09

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build is broken, code does not compile.

@dipak0000812 dipak0000812 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.

Hi @PranjaliBhardwaj
The build failure comes from the logging statement, not the ResponseEntity change.

Microcks uses JBoss Logging, which does not support SLF4J-style {} placeholders.
This line:

log.warn("Secret '{}' specified in test request but not found", test.getSecretName());

ends up matching the (String, Throwable) overload, causing:
String cannot be converted to Throwable.

Using String.format(...) or string concatenation here should fix the compilation error and unblock build-install.

@lbroudoux

lbroudoux commented Jan 21, 2026 •

Copy link
Copy Markdown
Member

Microcks uses JBoss Logging, which does not support SLF4J-style {} placeholders.

In fact, it's a bit more complex 😉 JBoss Logging is used in the async-minion that is written in Quarkus but the main app component (webapp) is written in Spring and uses SL4J.

Moreover, in the webapp component, we've wrapped common SL4J with a SafeLogger to prevent logging user-entered input (a security best practice). The remaining error is because the warn() method with the signature you chose doesn't exist on SafeLogger.

Actually, it's better to check that your PR locally compiles before submitting them...

Signed-off-by: Pranjali Bhardwaj <[email protected]>
@PranjaliBhardwaj

Copy link
Copy Markdown
Contributor Author

ok, new approach to handle this problem:
The Problem
SafeLogger only had warn(String message, Throwable t), not warn(String message). When TestController called log.warn("Secret '" + test.getSecretName() + "' specified..."), the compiler tried to match warn(String, Throwable) and failed because a String can't be converted to Throwable.
The Solution
Added the missing warn(String message) method to SafeLogger, matching the pattern used for debug(), info(), and error(). This allows TestController to call log.warn() with a single string argument.

As I was learning the project, I may have made a few mistakes. I hope they did not come across negatively.
Thank you for mentoring me @lbroudoux and @dipak0000812

@lbroudoux lbroudoux left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the changes and your patience!

@lbroudoux lbroudoux added this to the Next milestone Feb 4, 2026
@lbroudoux
lbroudoux merged commit bfa1bc4 into microcks:1.13.x Feb 4, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants