Skip to content

Commit

Permalink
feat(bpdm-gate): Extend error code
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyao-cofinity-x committed Dec 4, 2024
1 parent a956e5c commit 9ef00b1
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 32 deletions.
52 changes: 33 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ The format is based on Keep a Changelog (https://keepachangelog.com/en/1.0.0/),

For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/CHANGELOG.md) of the charts directly.

## [6.2.0] - tbd
## [6.3.0] - tbd

### Added

- BPDM Pool: Post endpoint to fetch the BPNL/S/A based on the requested identifiers.([#1052](https://github.com/eclipse-tractusx/bpdm/issues/1052))
- BPDM Gate & Orchestrator: Enhance the error handling mechanism for the orchestrator and gate components by extending the list of available error codes.([#1003](https://github.com/eclipse-tractusx/bpdm/pull/1003#pullrequestreview-2477395867))

### Changed

- BPDM Gate: Fetched and updated legal name of legal entity from pool while performing partner upload process via CSV([#1141](https://github.com/eclipse-tractusx/bpdm/issues/1141))
- BPDM Orchestrator: When trying to resolve tasks for a step that have has been resolved before, the request is ignored. A HTTP OK instead of a BadRequest will be returned ([#1092](https://github.com/eclipse-tractusx/bpdm/issues/1092))


## [6.2.0] - 2024-11-28

### Added

Expand Down Expand Up @@ -41,6 +54,7 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C
- BPDM Cleaning Service Dummy: Removed assignment of uncategorized identifier while performing cleaning task process. ([#1098](https://github.com/eclipse-tractusx/bpdm/pull/1098))
- BPDM Pool: Fix error querying legal forms when non-gleif legacy legal forms are present in the database ([#1107](https://github.com/eclipse-tractusx/bpdm/issues/1107))
- BPDM: Fix denial of service attack vulnerability CVE-2024-47535 ([#1112](https://github.com/eclipse-tractusx/bpdm/issues/1112))
- BPDM Gate: Fix error on writing golden record task result missing legal name into output stage. Result is now correctly written. ([#1115](https://github.com/eclipse-tractusx/bpdm/issues/1115))

## [6.1.0] - [2024-07-15]

Expand All @@ -50,7 +64,7 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C
- BPDM Gate: GET endpoint to download the csv file template for business partner upload. ([#700](https://github.com/eclipse-tractusx/sig-release/issues/700))
- Apps: Tax Jurisdiction Code to the physical address of a business partner ([#955](https://github.com/eclipse-tractusx/bpdm/issues/955))
- BPDM Orchestrator: Tasks will now be persisted ([#722](https://github.com/eclipse-tractusx/sig-release/issues/722))
- BPDM Orchestrator: Tasks now come with a gate record identifier. This makes it possible for cleaning services to match tasks for the same Gate record ([#711](https://github.com/eclipse-tractusx/sig-release/issues/711))
- BPDM Orchestrator: Tasks now come with a gate record identifier. This makes it possible for cleaning services to match tasks for the same Gate record ([#711](https://github.com/eclipse-tractusx/sig-release/issues/711))

### Changed:

Expand Down Expand Up @@ -93,15 +107,15 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C

### Added

- BPDM Gate: Configuration to prevent the uploaded business partner input data to immediately enter the golden record process.
In this configuration the business partner data needs to be sent to the golden record process manually over the new state/ready API endpoint.
Default configuration remains automatically sharing.
- BPDM Gate: Configuration to prevent the uploaded business partner input data to immediately enter the golden record process.
In this configuration the business partner data needs to be sent to the golden record process manually over the new state/ready API endpoint.
Default configuration remains automatically sharing.
- BPDM Gate: Limited multi-tenancy support. Business partners are now separated by owner-BPNL.
The owner is determined from the 'bpn' claim in the token.
This means users of a Gate can only see and edit their own business partner data.
The owner is determined from the 'bpn' claim in the token.
This means users of a Gate can only see and edit their own business partner data.
- BPDM Pool: New API endpoints to query business partner data which belongs to Catena-X members only
- APIs: Added a major version number to all API endpoint paths indicating the current version of the BPDM APIs.
In the future we will use version numbers in the URL to differentiate between all currently supported major versions of the API
In the future we will use version numbers in the URL to differentiate between all currently supported major versions of the API
- BPDM Gate Client: Now supports the stats endpoints of the BPDM API

### Changed
Expand All @@ -113,15 +127,15 @@ In the future we will use version numbers in the URL to differentiate between al
- BPDM Gate: Fix not correctly updating business partner output data from golden record updates in the Pool.
- JAVA version to 21
- BPDM API Permissions: Overhaul of the permissions needed to access the BPDM API endpoints.
Permissions are now more fine-granular and differentiate more clearly between read or write.
For more details consult the Arc42, API documentation and properties files of the respective applications.
Permissions are now more fine-granular and differentiate more clearly between read or write.
For more details consult the Arc42, API documentation and properties files of the respective applications.
- BPDM App Configuration: Now all applications are secured (authenticated and authorized) by default.
You can still deactivate security in the BPDM apps for testing or development purposes though.
You can still deactivate security in the BPDM apps for testing or development purposes though.
- BPDM Pool: Fix Pool trying to update golden records which the golden record process indicated to have no changes
- BPDM Orchestrator: The business partner data for golden record process tasks has been completely overhauled.
Now business partner data is clearly divided into `uncategorized`, `legal entity`, `site` and `additonal address` data.
This model is less verbose and contains less duplicate data.
Additionally, both Pool and Gate can write and read from it making it unnecessary for a cleaning service to provide the data in two different models.
Now business partner data is clearly divided into `uncategorized`, `legal entity`, `site` and `additonal address` data.
This model is less verbose and contains less duplicate data.
Additionally, both Pool and Gate can write and read from it making it unnecessary for a cleaning service to provide the data in two different models.



Expand Down Expand Up @@ -169,7 +183,7 @@ Additionally, both Pool and Gate can write and read from it making it unnecessar
- BPDM Gate: New business partner type 'GENERIC' for changelog
- BPDM Gate: New business partner type 'GENERIC' for sharing state
- Workflows: Trivy now targets the latest alpha Docker image instead of the latest release version
- Apps: Increase projectreactor.netty version to fix Trivy vulnerability
- Apps: Increase projectreactor.netty version to fix Trivy vulnerability


## [4.0.1] - 2023-08-28
Expand Down Expand Up @@ -207,8 +221,8 @@ Please create a back-up of your business partner data before updating.
- BPDM: Umbrella Chart with BPDM Bridge Dummy.

### Fixed
- BPDM: Deprecated endpoints for retrieving business partners in legacy format.
- Endpoint for retrieving changelog entries has now improved filtering (breaking API change)
- BPDM: Deprecated endpoints for retrieving business partners in legacy format.
- Endpoint for retrieving changelog entries has now improved filtering (breaking API change)

## [3.2.2] - 2023-05-12

Expand Down Expand Up @@ -252,7 +266,7 @@ Please create a back-up of your business partner data before updating.

### Fixed

- BPDM Gate: For a business partner with a child relation, this relation could be returned as parent relation erroneously.
- BPDM Gate: For a business partner with a child relation, this relation could be returned as parent relation erroneously.
- BPDM Gate: When a business partner with a child relation was updated, this relation was erroneously deleted, rendering the previous child invalid.

## [3.0.3] - 2023-02-23
Expand Down Expand Up @@ -330,4 +344,4 @@ Please create a back-up of your business partner data before updating.

### Deprecated

- Endpoints for retrieving business partners in legacy format
- Endpoints for retrieving business partners in legacy format
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.eclipse.tractusx.bpdm.gate.api.exception

import io.swagger.v3.oas.annotations.media.Schema

/**
* For every combination of possible errors a separate enum class is defined extending this marker interface.
* We need separate enum classes in order to get the correct error codes for each endpoint in the Swagger schema.
Expand All @@ -30,6 +32,12 @@ enum class BusinessPartnerSharingError : ErrorCode {
SharingTimeout,
BpnNotInPool,
MissingTaskID,
NaturalPersonError,
BpnErrorNotFound,
BpnErrorTooManyOptions,
MandatoryFieldValidationFailed,
BlacklistCountryPresent,
UnknownSpecialCharacters
}

enum class ChangeLogOutputError : ErrorCode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import java.time.LocalDateTime
@Schema(
description = "A sharing state entry shows the progress in the sharing process and is updated each time the " +
"progress for a business partner changes. The business partner is identified by a combination " +
"of external ID and business partner type."
)
"of external ID and business partner type.\n")
data class SharingStateDto(

@get:Schema(description = "The external identifier of the business partner for which the sharing state entry was created.")
Expand All @@ -37,7 +36,13 @@ data class SharingStateDto(
@get:Schema(description = "One of the sharing state types of the current sharing state.")
val sharingStateType: SharingStateType = SharingStateType.Initial,

@get:Schema(description = "One of the sharing error codes in case the current sharing state type is \"error\".")
@get:Schema(description = "One of the sharing error codes in case the current sharing state type is \"error\". \n" +
"* `NaturalPersonError`: The provided record contains natural person information.\n" +
"* `BpnErrorNotFound`: The provided record can not be matched to a legal entity or an address.\n" +
"* `BpnErrorTooManyOptions`: The provided record can not link to a clear legal entity.\n" +
"* `MandatoryFieldValidationFailed`: The provided record does not fulfill mandatory validation rules.\n" +
"* `BlacklistCountryPresent`: The provided record is part of a country that is not allowed to be processed by the GR process (example: Brazil).\n" +
"* `UnknownSpecialCharacters`: The provided record contains unallowed special characters.")
val sharingErrorCode: BusinessPartnerSharingError? = null,

@get:Schema(description = "The error message in case the current sharing state type is \"error\".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.eclipse.tractusx.orchestrator.api.model.ResultState
import org.eclipse.tractusx.orchestrator.api.model.TaskClientStateDto
import org.eclipse.tractusx.orchestrator.api.model.TaskResultStateSearchRequest
import org.eclipse.tractusx.orchestrator.api.model.TaskStateRequest
import org.eclipse.tractusx.orchestrator.api.model.*
import org.springframework.data.domain.PageRequest
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
Expand Down Expand Up @@ -171,11 +172,22 @@ class TaskResolutionChunkService(
return when (task.processingState.resultState) {
ResultState.Pending -> RequestCreationResult(sharingState, null, null, null)
ResultState.Success -> createUpsertRequestForSuccessfulTask(sharingState, task, input)
ResultState.Error -> RequestCreationResult.error(
sharingState,
BusinessPartnerSharingError.SharingProcessError,
if (task.processingState.errors.isNotEmpty()) task.processingState.errors.joinToString(" // ") { it.description }.take(255) else null
)
ResultState.Error -> handleTaskErrorResult(sharingState, task)
}
}

private fun handleTaskErrorResult( sharingState: SharingStateDb, task: TaskClientStateDto): RequestCreationResult {
val errorDescription = task.processingState.errors.joinToString(" // ") { it.description }.take(255).ifEmpty { null }

return when (task.processingState.errors.firstOrNull()?.type) {
TaskErrorType.Timeout -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.SharingTimeout, errorDescription)
TaskErrorType.NaturalPersonError -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.NaturalPersonError, errorDescription)
TaskErrorType.BpnErrorNotFound -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.BpnErrorNotFound, errorDescription)
TaskErrorType.BpnErrorTooManyOptions -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.BpnErrorTooManyOptions, errorDescription)
TaskErrorType.MandatoryFieldValidationFailed -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.MandatoryFieldValidationFailed, errorDescription)
TaskErrorType.BlacklistCountryPresent -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.BlacklistCountryPresent, errorDescription)
TaskErrorType.UnknownSpecialCharacters -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.UnknownSpecialCharacters, errorDescription)
else -> RequestCreationResult.error(sharingState, BusinessPartnerSharingError.SharingProcessError, errorDescription )
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor(
SharingStateDto(
externalId = externalId5,
sharingStateType = SharingStateType.Error,
sharingErrorCode = BusinessPartnerSharingError.SharingProcessError,
sharingErrorCode = BusinessPartnerSharingError.SharingTimeout,
sharingErrorMessage = "Major Error // Minor Error",
sharingProcessStarted = null,
taskId = "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class BusinessPartnerControllerIT @Autowired constructor(
SharingStateDto(
externalId = externalId5,
sharingStateType = SharingStateType.Error,
sharingErrorCode = BusinessPartnerSharingError.SharingProcessError,
sharingErrorCode = BusinessPartnerSharingError.SharingTimeout,
sharingErrorMessage = "Major Error // Minor Error",
sharingProcessStarted = null,
taskId = "1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ package org.eclipse.tractusx.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "Describes an error that happened during processing of a task")
@Schema(description = "Describes an error that happened during processing of a task \n")
data class TaskErrorDto(

@get:Schema(description = "The type of error that occurred", required = true)
@get:Schema(description = "The type of error that occurred. \n" +
"* `NaturalPersonError`: The provided record contains natural person information.\n" +
"* `BpnErrorNotFound`: The provided record can not be matched to a legal entity or an address.\n" +
"* `BpnErrorTooManyOptions`: The provided record can not link to a clear legal entity.\n" +
"* `MandatoryFieldValidationFailed`: The provided record does not fulfill mandatory validation rules.\n" +
"* `BlacklistCountryPresent`: The provided record is part of a country that is not allowed to be processed by the GR process (example: Brazil).\n" +
"* `UnknownSpecialCharacters`: The provided record contains unallowed special characters.\n" , required = true)
val type: TaskErrorType,

@get:Schema(description = "The free text, detailed description of the error", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@

package org.eclipse.tractusx.orchestrator.api.model

import io.swagger.v3.oas.annotations.media.Schema

enum class TaskErrorType {
Timeout,
Unspecified
Unspecified,
NaturalPersonError,
BpnErrorNotFound,
BpnErrorTooManyOptions,
MandatoryFieldValidationFailed,
BlacklistCountryPresent,
UnknownSpecialCharacters
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ALTER TABLE task_errors DROP CONSTRAINT task_errors_type_check;
ALTER TABLE task_errors ADD CONSTRAINT task_errors_type_check CHECK (type IN (
'Timeout',
'Unspecified',
'NaturalPersonError',
'BpnErrorNotFound',
'BpnErrorTooManyOptions',
'MandatoryFieldValidationFailed',
'BlacklistCountryPresent',
'UnknownSpecialCharacters'
));
6 changes: 6 additions & 0 deletions docs/api/gate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,12 @@ components:
- SharingTimeout
- BpnNotInPool
- MissingTaskID
- NaturalPersonError
- BpnErrorNotFound
- BpnErrorTooManyOptions
- MandatoryFieldValidationFailed
- BlacklistCountryPresent
- UnknownSpecialCharacters
sharingErrorMessage:
type: string
description: The error message in case the current sharing state type is "error".
Expand Down
6 changes: 6 additions & 0 deletions docs/api/orchestrator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,12 @@ components:
enum:
- Timeout
- Unspecified
- NaturalPersonError
- BpnErrorNotFound
- BpnErrorTooManyOptions
- MandatoryFieldValidationFailed
- BlacklistCountryPresent
- UnknownSpecialCharacters
description:
type: string
description: The free text, detailed description of the error
Expand Down

0 comments on commit 9ef00b1

Please sign in to comment.