Skip to content

Conversation

@AnkitCLI
Copy link
Contributor

@AnkitCLI AnkitCLI commented Feb 24, 2025

Description
Error Management for Google Publisher Sink plugin exceptions

https://cdap.atlassian.net/browse/PLUGIN-1868

Code change
Modified GooglePublisher.java
Added GooglePublisherErrorDetailsProvider.java
Modified GCPUtils.java
Modified PubSubOutputFormat.java

Tests
Test Case - tested with valid and invalid scenarios

1. Success

Screenshot 2025-02-24 at 9 17 36 PM

2. Permission denied to create topic

image image

Logs
Screenshot 2025-02-24 at 9 23 27 PM

3. Failed to publish records
image

image

BQ plugin after changes
image
image

GCS move plugin after changes
image
image

@AnkitCLI AnkitCLI added the build Trigger unit test build label Feb 24, 2025
@AnkitCLI AnkitCLI marked this pull request as ready for review February 24, 2025 16:13
@AnkitCLI AnkitCLI requested a review from psainics February 24, 2025 16:18
@psainics psainics marked this pull request as draft February 25, 2025 06:54
@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch 3 times, most recently from 1a3d5fe to 764c443 Compare February 27, 2025 06:12
@AnkitCLI AnkitCLI marked this pull request as ready for review February 27, 2025 06:12
@psainics psainics changed the title Error Management for Google Publisher [PLUGIN-1868] Error Management for Google Publisher Feb 27, 2025
Comment on lines 123 to 129
String error = String.format(
"Could not auto-create topic '%s' in project '%s'. "
+ "Please ensure it is created before running the pipeline, "
+ "or ensure that the service account has permission to create the topic.",
config.topic, projectId);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, ErrorType.USER, false, e1);
Copy link
Contributor

Choose a reason for hiding this comment

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

ApiException should have much more details, like statusCode which can help in computing error type. Dependency should also be true.

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 with the status code and dependency

Comment on lines 273 to 276
String error = String.format("Error publishing records to PubSub: %s", e.getMessage());
throw ErrorUtils.getProgramFailureException(
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, ErrorType.USER, false, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

can ExecutionException contain GoogleJsonResponseException or ApiException? Did we check the stacktrace?

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 and SS attached in the description.

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from 764c443 to 0837503 Compare March 3, 2025 05:23
+ "Status code: %d.",
config.topic, projectId, statusCode);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, ErrorType.USER, true, e1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add errorCode, errorType and supportDocUrl to the exception.

This comment applies to the whole PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from 0837503 to d12ef2f Compare March 3, 2025 08:15
@psainics psainics requested a review from itsankit-google March 3, 2025 14:18
String errorMessage = String.format("Failed to publish %s records: %s. For more details, see %s",
failures.get(), error.get(), GCPUtils.PUBSUB_SUPPORTED_DOC_URL);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
errorMessage, errorMessage, ErrorType.USER, false, null, null, GCPUtils.PUBSUB_SUPPORTED_DOC_URL, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not add support doc when error is not from external client.

Why error type USER?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doc removed, changed user to unknown

Comment on lines 276 to 275
throw GCPErrorDetailsProviderUtil.getHttpResponseExceptionDetailsFromChain(e, errorReason, ErrorType.USER,
true, GCPUtils.PUBSUB_SUPPORTED_DOC_URL);
Copy link
Contributor

Choose a reason for hiding this comment

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

can ExecutionException contain GoogleJsonResponseException or ApiException? Did we check the stacktrace?

Why error type USER?

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we make this unknown, error type is correctly detected when using getHttpResponseExceptionDetailsFromChain using the http error codes, else it should be unknown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to UNKNOWN

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from d12ef2f to ef5d48f Compare March 3, 2025 15:57
@AnkitCLI AnkitCLI requested a review from itsankit-google March 4, 2025 05:46
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.

why does the 3rd screenshot in PR description does not have errorCode in the response?

Didn't the stacktrace had GoogleJsonResponseException? If not then we should also handle ApiException in GcpErrorDetailsProviderUtil.

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from ef5d48f to 5de6a5d Compare March 4, 2025 17:51
@AnkitCLI
Copy link
Contributor Author

AnkitCLI commented Mar 4, 2025

why does the 3rd screenshot in PR description does not have errorCode in the response?

Didn't the stacktrace had GoogleJsonResponseException? If not then we should also handle ApiException in GcpErrorDetailsProviderUtil.

Handled APiException in GcpErrorDetailsProviderUtil. Attached updated SS in the description .

@AnkitCLI AnkitCLI requested a review from itsankit-google March 4, 2025 18:02
@itsankit-google
Copy link
Contributor

itsankit-google commented Mar 4, 2025

why does the 3rd screenshot in PR description does not have errorCode in the response?
Didn't the stacktrace had GoogleJsonResponseException? If not then we should also handle ApiException in GcpErrorDetailsProviderUtil.

Handled APiException in GcpErrorDetailsProviderUtil. Attached updated SS in the description .

Did we check the stacktrace? This change will affect all GCP plugins. Can you please add the stacktrace and pipeline logs?

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch 3 times, most recently from ca2a4cf to da97000 Compare March 5, 2025 07:16
@AnkitCLI
Copy link
Contributor Author

AnkitCLI commented Mar 5, 2025

why does the 3rd screenshot in PR description does not have errorCode in the response?
Didn't the stacktrace had GoogleJsonResponseException? If not then we should also handle ApiException in GcpErrorDetailsProviderUtil.

Handled APiException in GcpErrorDetailsProviderUtil. Attached updated SS in the description .

Did we check the stacktrace? This change will affect all GCP plugins. Can you please add the stacktrace and pipeline logs?

Yes we checked the stacktrace
Pasted Graphic

@AnkitCLI AnkitCLI requested review from itsankit-google and removed request for itsankit-google March 5, 2025 07:22
@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from da97000 to a4e67aa Compare March 6, 2025 10:39
+ "For more details, see %s",
config.topic, projectId, GCPUtils.PUBSUB_SUPPORTED_DOC_URL);
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
error, error, ErrorType.USER, true, ErrorCodeType.HTTP, String.valueOf(statusCode),
Copy link
Contributor

Choose a reason for hiding this comment

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

ErrorType.UNKNOWN by default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from a4e67aa to 925273a Compare March 6, 2025 13:42
@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from 925273a to c7457f5 Compare March 6, 2025 16:28
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.

Can you please also re-test somecases of GCS & BQ plugin to verify they are working as expected after these changes?

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from c7457f5 to 264f1c5 Compare March 6, 2025 17:35
@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch from 264f1c5 to 6d9a2e4 Compare March 7, 2025 06:14
Comment on lines 53 to 58
if (t instanceof IllegalArgumentException) {
return getProgramFailureException((IllegalArgumentException) t, errorContext);
}
if (t instanceof IllegalStateException) {
return getProgramFailureException((IllegalStateException) t, errorContext);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

these two checks can also go in later loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@AnkitCLI AnkitCLI force-pushed the em/googlePublisher branch 2 times, most recently from 5ab28c9 to 2570569 Compare March 7, 2025 06:43
@AnkitCLI
Copy link
Contributor Author

AnkitCLI commented Mar 7, 2025

Can you please also re-test somecases of GCS & BQ plugin to verify they are working as expected after these changes?

checkedn with GCS and BQ both. Working fine.

@AnkitCLI AnkitCLI requested a review from itsankit-google March 8, 2025 07:19
@psainics psainics force-pushed the em/googlePublisher branch from 2570569 to 6a78e55 Compare March 10, 2025 06:13
@psainics psainics merged commit 7a2575c into data-integrations:develop Mar 10, 2025
16 checks passed
@psainics psainics deleted the em/googlePublisher branch March 10, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Trigger unit test build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants