Skip to content

Conversation

@palatsangeetha
Copy link
Collaborator

@palatsangeetha palatsangeetha commented Dec 15, 2025

PR Type

Enhancement


Description

  • Add reason field to root level of error response

  • Applies to rejection scenarios (BREQ and REFU codes)

  • Maintains existing error details in nested structure


Diagram Walkthrough

flowchart LR
  A["Error Response<br/>BREQ or REFU"] --> B["Root Level<br/>reason field"]
  A --> C["Nested errors<br/>array with reason"]
  B -- "New addition" --> D["Rejection reason"]
  C -- "Existing" --> D
Loading

File Walkthrough

Relevant files
Enhancement
EblIssuancePlatform.java
Add root-level reason field for rejection responses           

ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuancePlatform.java

  • Added reason field at root level of platform response for rejection
    scenarios
  • Field is populated with "Rejected as required by the conformance
    scenario" message
  • Applies when response code is BREQ or REFU
  • Complements existing nested error reason field
+1/-0     

@qodo-code-review
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟢
🎫 #SD-2749
🟢 When issuanceResponseCode is not ISSU, include a root-level reason field in the response.
For the BREQ and REFU conformance scenarios, set the root-level reason to the same value
as errors[].reason (copy from errors/reason).
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Extract duplicated strings into constants

Extract the duplicated string literal "Rejected as required by the conformance
scenario" and the hardcoded error code "DCSA-123" into private static final
constants to improve maintainability.

ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuancePlatform.java [191-198]

+private static final String REJECTION_REASON = "Rejected as required by the conformance scenario";
+private static final String CONFORMANCE_ERROR_CODE = "DCSA-123";
+...
 if (scenarioResponseCode.equals("BREQ") || scenarioResponseCode.equals("REFU")) {
-  platformResponse.put("reason", "Rejected as required by the conformance scenario");
+  platformResponse.put("reason", REJECTION_REASON);
   platformResponse
       .putArray("errors")
       .addObject()
-      .put("reason", "Rejected as required by the conformance scenario")
-      .put("errorCode", "DCSA-123");
+      .put("reason", REJECTION_REASON)
+      .put("errorCode", CONFORMANCE_ERROR_CODE);
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies duplicated string literals, one of which was introduced in the PR, and proposes extracting them into constants, which improves code maintainability.

Low
Use a Set for condition checking

Replace the || condition with Set.of("BREQ",
"REFU").contains(scenarioResponseCode) for improved readability and scalability
when checking for rejection codes.

ebl-issuance/src/main/java/org/dcsa/conformance/standards/eblissuance/party/EblIssuancePlatform.java [191-198]

-if (scenarioResponseCode.equals("BREQ") || scenarioResponseCode.equals("REFU")) {
+if (Set.of("BREQ", "REFU").contains(scenarioResponseCode)) {
   platformResponse.put("reason", "Rejected as required by the conformance scenario");
   platformResponse
       .putArray("errors")
       .addObject()
       .put("reason", "Rejected as required by the conformance scenario")
       .put("errorCode", "DCSA-123");
 }
  • Apply / Chat
Suggestion importance[1-10]: 3

__

Why: This is a valid stylistic suggestion that can improve readability, but for only two conditions, the original || check is also clear and the suggested change offers only a marginal improvement.

Low
  • More

@palatsangeetha palatsangeetha merged commit 5874ab1 into dev Dec 15, 2025
1 check passed
@palatsangeetha palatsangeetha deleted the SD-2749-ebl-issuance-missing-reason branch December 15, 2025 13:40
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