eclipse-tractusx / portal-backend

Portal Backend
Apache License 2.0
7 stars 19 forks source link

Process worker fails in BPN creation because calls unnecessary endpoint /v6/sharing-state/ready #830

Closed gomezbc closed 4 weeks ago

gomezbc commented 1 month ago

Current Behavior

During company onboarding process, in BPN Creation step, after the processworker has successfully created the business partner, it calls this Gate endpoint /v6/sharing-state/ready which returns a 400 error, because the creation of the business partner already sets sharingStateType to Ready.

As stated here, https://github.com/eclipse-tractusx/bpdm/blob/main/docs/api/README.md#sharing-state, unless BPDM API is configured to support an additional 'Initial' sharing state, /v6/sharing-state/ready call is unnecessary and results in an error. Re-triggering the process doesn't solve the issue, and a custom SQL script is needed to manually set the BPN number and trigger the next step.

[!note] The request /v6/sharing-state/ready only success if the sharingStateType is set to Initial or Error. Ready or Success states will always return 400 error.

The error log from the Gate:

The following business partners are in an invalid state: InvalidState(externalId=74162c13-83df-4f26-9d90-04eea16d8a83, stateType=Ready)

Expected Behavior

I think, that a toggle to disable this call should be provided. Or, if this call is unnecessary in all use cases, it should be removed.

Steps To Reproduce

BPDM chart: v5.0.2, BPDM: v6.0.2 Portal chart: v2.0.0

evegufy commented 1 month ago

Hi @Phil91 @ntruchsess @MaximilianHauer could you please have a look?

Phil91 commented 1 month ago

Hey @gomezbc sorry for the late response, was on vacation. It seems we used the bpd with starts-as-readyset to false. It totally make sense to introduce a new toggle to skip the sharing-state/readycall

gomezbc commented 1 month ago

@Phil91, no worries, thanks for letting me know! Introducing a new toggle sounds like a great idea.

nicoprow commented 1 month ago

@gomezbc

This seems to be a configuration issue with the BPDM Gate. The Portal needs a BPDM Gate that is configured to manually start the golden record process after creating new business partners. The Gate comes in two configurations: Manually setting new business partners to the golden record process and automatically sending upserted bsuiness partner data to the golden record process.

Here is the configuration of the BPDM Gate that this refers to: https://github.com/eclipse-tractusx/bpdm/blob/release/6.0.x/bpdm-gate/src/main/resources/application.yml

tasks:
    creation:
      fromSharingMember:
        # If true, new business partner input data will be directly ready to be shared
        # If false, new business partner input data need to be manually set to ready
        starts-as-ready: true

A Gate being setup for the Portal needs starts-as-ready to be set to false

Very soon I will provide a configuration in https://github.com/eclipse-tractusx/tractus-x-umbrella to show a BPDM setup that the Portal can integrate against.

gomezbc commented 1 month ago

Thanks, @nicoprow! That worked perfectly. It would be helpful to include this information in the developer documentation of portal-assets. The default BPDM configuration being opposite to the backend process can be confusing.

Phil91 commented 1 month ago

@gomezbc I've added an issue to add the feature toggle in the backend, depending on the priorization I would directly add the feature toggle and the configuration for that instead of adding the documentation in portal-assets for the bpdm. If the priorization for the issue is set to low we can add the documentation for bpdm to the portal-assets repo

evegufy commented 4 weeks ago

followed up with https://github.com/eclipse-tractusx/portal-backend/issues/845