Skip to content

Remove DBErrorDetailsProvider#543

Merged
psainics merged 1 commit intodata-integrations:developfrom
cloudsufi:fem/generic-sqlstate-classification
Jan 29, 2025
Merged

Remove DBErrorDetailsProvider#543
psainics merged 1 commit intodata-integrations:developfrom
cloudsufi:fem/generic-sqlstate-classification

Conversation

@psainics
Copy link
Contributor

@psainics psainics commented Jan 26, 2025

Remove DBErrorDetailsProvider

Description

  • Remove DBErrorDetailsProvider
  • Move Doc Link from error message to error reason.

Code change

  • Deleted DBErrorDetailsProvider.java
  • Modified AbstractDBSink.java
  • Modified AbstractDBSource.java
  • Modified MysqlErrorDetailsProvider.java
  • Modified PostgresErrorDetailsProvider.java

Tests [ MySql ]

image

[
  {
    "stageName": "MySQL2",
    "errorCategory": "Plugin-'DB Integrity Constraint Violation'-'MySQL2'",
    "errorReason": "Duplicate entry '1' for key 'PRIMARY'. For more details, see https://dev.mysql.com/doc/mysql-errors/9.0/en/",
    "errorMessage": "Error occurred in the phase: 'Writing' with sqlState: '23000', errorCode: '1062', errorMessage: Duplicate entry '1' for key 'PRIMARY'",
    "errorType": "USER",
    "dependency": "true",
    "errorCodeType": "SQLSTATE",
    "errorCode": "23000",
    "supportedDocumentationUrl": "https://dev.mysql.com/doc/mysql-errors/9.0/en/"
  }
]

Tests [ postgresql ]

image

[
  {
    "stageName": "PostgreSQL2",
    "errorCategory": "Plugin-'Postgres Integrity Constraint Violation'-'PostgreSQL2'",
    "errorReason": "Batch entry 0 INSERT INTO \"user2\" (\"id\",\"name\",\"age\",\"gender\") VALUES (1,'Alice',25,'female') was aborted: ERROR: duplicate key value violates unique constraint \"user2_pkey\"\n  Detail: Key (id)=(1) already exists.  Call getNextException to see other errors in the batch. For more details, see https://www.postgresql.org/docs/current/errcodes-appendix.html",
    "errorMessage": "Error occurred in the phase: 'Writing' with sqlState: '23505', errorCode: '0', errorMessage: Batch entry 0 INSERT INTO \"user2\" (\"id\",\"name\",\"age\",\"gender\") VALUES (1,'Alice',25,'female') was aborted: ERROR: duplicate key value violates unique constraint \"user2_pkey\"\n  Detail: Key (id)=(1) already exists.  Call getNextException to see other errors in the batch.",
    "errorType": "USER",
    "dependency": "true",
    "errorCodeType": "SQLSTATE",
    "errorCode": "23505",
    "supportedDocumentationUrl": "https://www.postgresql.org/docs/current/errcodes-appendix.html"
  }
]

@psainics psainics added the build label Jan 26, 2025
@psainics psainics self-assigned this Jan 26, 2025
@psainics psainics marked this pull request as ready for review January 27, 2025 03:11
@psainics psainics force-pushed the fem/generic-sqlstate-classification branch from 5f51a10 to 1e1c536 Compare January 28, 2025 11:01
@psainics psainics changed the title Implements generic error types based on the SQL state. Remove DBErrorDetailsProvider Jan 28, 2025
@psainics psainics force-pushed the fem/generic-sqlstate-classification branch 2 times, most recently from b89815d to c23a385 Compare January 28, 2025 13:28
}
} catch (SQLException e) {
// wrap exception to ensure SQLException-child instances not exposed to contexts w/o jdbc driver in classpath
String errorMessage = e.getMessage();
Copy link
Contributor

Choose a reason for hiding this comment

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

errorReason should also contain errorCode & sqlState

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's in errorMessageWithDetails, we are not doing the same at other places.

Copy link
Contributor

Choose a reason for hiding this comment

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

In other plugins, we are adding errorCode information in errorReason as well, we should do the same in db-plugins as well for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

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

The format can be something like:

"SQL Exception occurred: [Message='%s', SQLState='%s', ErrorCode='%s']. For more details, see %s"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated error message !
Will be raising a PR for same change in hydrator-plugins !

Copy link
Contributor

@itsankit-google itsankit-google left a comment

Choose a reason for hiding this comment

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

please also do a similar test for Postgres as well.

@psainics
Copy link
Contributor Author

please also do a similar test for Postgres as well.

Added Postgres test !

@psainics psainics force-pushed the fem/generic-sqlstate-classification branch from c23a385 to 8d7e9cd Compare January 29, 2025 05:10
@psainics psainics merged commit 9674966 into data-integrations:develop Jan 29, 2025
8 of 10 checks passed
@psainics psainics deleted the fem/generic-sqlstate-classification branch January 29, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants