Skip to content
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

POJOActivityImplementation should not throw ActivityFailureException with details larger than 32k #28

Open
redparham opened this issue Jul 16, 2020 · 0 comments

Comments

@redparham
Copy link

redparham commented Jul 16, 2020

POJOActivityImplementation.throwActivityFailureException method throws ActivityFailureExceptions but doesn't truncate the "details" constructor param to 32k. This causes AmazonSimpleWorkflowClient.executeRespondActivityTaskFailed to fail:

Caused by: com.amazonaws.services.simpleworkflow.model.AmazonSimpleWorkflowException: 1 validation error detected: Value '...some error payload >32k...' at 'details' failed to satisfy constraint: Member must have length less than or equal to 32768 (Service: AmazonSimpleWorkflow; Status Code: 400; Error Code: ValidationException; Request ID: 741c57e6-e861-42f4-be70-3ab0d1f75761)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1712)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1367)
...
at com.amazonaws.services.simpleworkflow.AmazonSimpleWorkflowClient.respondActivityTaskFailed(AmazonSimpleWorkflowClient.java:3115)
...
at com.amazonaws.services.simpleworkflow.flow.worker.SynchronousActivityTaskPoller.execute(SynchronousActivityTaskPoller.java:211)
...

Notice that the 'reason' parameter is truncated - but not the details param:
com.amazonaws.services.simpleworkflow.flow.pojo.POJOActivityImplementation

void throwActivityFailureException(Throwable exception) 
            throws ActivityFailureException, CancellationException {
        
        if (exception instanceof CancellationException) {
            throw (CancellationException)exception;
        }
        
        String reason = WorkflowExecutionUtils.truncateReason(exception.getMessage());
        String details = null;
        try {
            details = converter.toData(exception);
        } catch (DataConverterException dataConverterException) {
            if (dataConverterException.getCause() == null) {
                dataConverterException.initCause(exception);
            }
            throw dataConverterException;
        }
        
        throw new ActivityFailureException(reason, details);
    }

I suggest truncating 'details' the same way as 'reason':
details = WorkflowExecutionUtils.truncateDetails(converter.toData(exception));

Feel free to assign this to me to fix by pull request... thanks.

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

No branches or pull requests

1 participant