Skip to content

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

@redparham

Description

@redparham

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions