fix(config-api): error message not indicating exact cause that SP name already exists by pujavs · Pull Request #12830 · JanssenProject/jans (original) (raw)

@pujavs

@pujavs pujavs commented

Dec 12, 2025

edited by coderabbitaiBot

Loading

Prepare


Description

Issue#12822: Error message not indicating exact cause that SP name already exists

Target issue

closes #12822

Implementation Details

Handled exception and throwing appropriate error message


Test and Document the changes

Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with docs: to indicate documentation changes or if the below checklist is not selected.

Summary by CodeRabbit

✏️ Tip: You can customize this high-level summary in your review settings.

@pujavs

Signed-off-by: pujavs pujas.works@gmail.com

@pujavs

@pujavs

@pujavs

Signed-off-by: pujavs pujas.works@gmail.com

@pujavs

… cause that SP name already exists #12822

Signed-off-by: pujavs pujas.works@gmail.com

@mo-auto

@coderabbitai

📝 Walkthrough

Walkthrough

Updates the TokenEntity schema in the API specification by adding two optional boolean properties (accessToken and logoutStatusJwt). Enhances error handling and logging in trust relationship REST resource for creation and update operations, with specific handling for WebApplicationException cases.

Changes

Cohort / File(s) Summary
API Schema Extensionjans-config-api/docs/jans-config-api-swagger.yaml Added accessToken and logoutStatusJwt as optional boolean properties to the TokenEntity schema.
Error Handling & Loggingjans-config-api/plugins/kc-saml-plugin/src/main/java/io/jans/configapi/plugin/saml/rest/TrustRelationshipResource.java Enhanced error handling in createTrustRelationshipWithFile and updateTrustRelationship methods with specific catch blocks for WebApplicationException that return the exception status and entity directly. Added debug and error logging around trust relationship creation, including detection of duplicate names. Updated log messages to clarify operation flow. Generic exception fallback retained.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The schema update to TokenEntity appears out of scope relative to the stated objective of fixing SP name duplicate error messaging. Remove the unrelated TokenEntity schema changes (adding accessToken and logoutStatusJwt properties) from this PR, as they do not address issue #12822.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.

✅ Passed checks (3 passed)

Check name Status Explanation
Title check ✅ Passed The title directly addresses the main issue: improving error messaging when an SP name already exists during SAML SP creation.
Description check ✅ Passed The description follows the template structure with target issue reference (#12822), implementation details mentioning exception handling, and documentation confirmation checkbox checked.
Linked Issues check ✅ Passed The PR implementation addresses the core requirement from issue #12822: enhanced exception handling now provides clearer error messages for duplicate SP names.

✨ Finishing touches


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

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

[coderabbitai[bot]](/apps/coderabbitai)

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 09506a1 and a9a3031.

📒 Files selected for processing (2)

jans-config-api/docs/jans-config-api-swagger.yaml (1)

17720-17729: The logoutStatusJwt field name is correct and consistent with the codebase; no action needed.

Verification confirms that logoutStatusJwt (camelCase with lowercase "wt") is the exact naming convention used throughout the server implementation (AppConfiguration, ClientAttributes, AuthorizationChallengeResponse, and related services). No naming mismatches or serialization issues exist.

Regarding descriptions: all fields in the TokenEntity and TokenAttributes schemas lack descriptions in the swagger.yaml. Adding descriptions only to accessToken and logoutStatusJwt would create inconsistency with the established schema pattern. If schema-wide documentation is desired, that would require a separate, comprehensive update.

jans-config-api/plugins/kc-saml-plugin/src/main/java/io/jans/configapi/plugin/saml/rest/TrustRelationshipResource.java (2)

135-135: LGTM: Logging enhancements aid troubleshooting.

The added debug and error logs improve observability when duplicate SP names are detected.

Also applies to: 140-140


157-164: Fix correctly preserves the duplicate-name error message.

By catching WebApplicationException separately before the generic Exception handler, the specific error from line 141 (NAME_CONFLICT_MSG) is now returned directly instead of being replaced by a generic internal server error. The throwBadRequestException method throws BadRequestException, which is a subclass of WebApplicationException, so the catch block at line 158 properly intercepts it and returns the original error response.

@sonarqubecloud

[coderabbitai[bot]](/apps/coderabbitai)

yuriyz

yurem

@yurem

@yurem yurem deleted the jans-config-api-12813 branch

December 15, 2025 13:02

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})