Skip to content

Add proper status for failed nodes. #6672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

inthirakumaaran
Copy link
Contributor

@inthirakumaaran inthirakumaaran commented Apr 9, 2025

Proposed changes in this pull request

Fix flow status in the fail() function

Issue

Copy link

sonarqubecloud bot commented Apr 9, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link

codecov bot commented Apr 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.85%. Comparing base (55ffca5) to head (45fc74d).
Report is 900 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6672      +/-   ##
============================================
+ Coverage     47.37%   47.85%   +0.48%     
- Complexity    15890    16150     +260     
============================================
  Files          1820     1823       +3     
  Lines        109188   110133     +945     
  Branches      20426    20395      -31     
============================================
+ Hits          51726    52708     +982     
+ Misses        50293    50178     -115     
- Partials       7169     7247      +78     
Flag Coverage Δ
unit 32.01% <100.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PasinduYeshan
Copy link
Contributor

PasinduYeshan commented Apr 10, 2025

Observation on Basic Auth failure response:

Without the fix:
200

{
    "flowStatus": "SUCCESS_COMPLETED",
    "authData": {
        "error_description": "Password has expired.",
        "error": "ABA-60003"
    }
}

With the fix:
400 Bad Request

{
    "code": "ABA-60002",
    "message": "ABA-60003 - Password has expired.",
    "description": "Authentication flow has concluded with a failure.",
    "traceId": "65a09c57-6c19-4241-af0f-7136ed669598"
}

This constitutes a breaking change, especially for clients or consumers that relied on the previous 200 OK response pattern. Any logic keyed on status code or "flowStatus" will likely need updating to align with the new error structure.

@inthirakumaaran
Copy link
Contributor Author

@PasinduYeshan

However, in the standard (UI-based) login flow, we maintain the current behavior (status code will be 200). For app-native authentication, this would be a significant change but one we should accept in order to ensure the correct behavior. On that note, we don't need a flowStatus for the FAIL_COMPLETED flow.

@Lakshan-Banneheke
Copy link
Contributor

Since this change only impacts users on version 7.0.0 and above, specifically when using the fail() function in adaptive scripts with app-native authentication, it has been agreed upon by the stakeholders to make a configuration available on demand and proceed with the proposed fix without introducing a config.

@Lakshan-Banneheke Lakshan-Banneheke marked this pull request as ready for review June 19, 2025 09:06
@Copilot Copilot AI review requested due to automatic review settings June 19, 2025 09:06
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that when authentication fails, the flow status is explicitly marked as FAIL_COMPLETED on the request.

  • Sets the FLOW_STATUS attribute to FAIL_COMPLETED in the handleAuthFail method.
  • Corrects the flow status handling for failed nodes.
Comments suppressed due to low confidence (2)

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/GraphBasedSequenceHandler.java:458

  • Add or update unit/integration tests to verify that the FLOW_STATUS attribute is set to FAIL_COMPLETED on the request when authentication fails.
            request.setAttribute(FrameworkConstants.RequestParams.FLOW_STATUS, AuthenticatorFlowStatus.FAIL_COMPLETED);

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/handler/sequence/impl/GraphBasedSequenceHandler.java:458

  • [nitpick] Consider extracting status updates into a shared helper or constant-driven utility method to ensure consistency across different failure handling paths.
            request.setAttribute(FrameworkConstants.RequestParams.FLOW_STATUS, AuthenticatorFlowStatus.FAIL_COMPLETED);

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/15754054721

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/15754054721
Status: failure

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/15754568261

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/15754568261
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/15754568261

@Lakshan-Banneheke Lakshan-Banneheke merged commit 36eed27 into wso2:master Jun 20, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants