fix(swf): report the live service's TypeNotDeprecatedFault message

DeleteWorkflowType/DeleteActivityType against a still-registered type
reported the type descriptor, e.g. "WorkflowType=[name=W, version=1]". The
live service answers with prose instead, and uses the same wording for both
type kinds:

  {"__type":"com.amazonaws.swf.base.model#TypeNotDeprecatedFault",
   "message":"The type is currently registered and cannot be deleted in its
              current state"}

Since both variants are identical, the two fault factories collapse into one.
The descriptor form is still correct for the other type faults
(TypeDeprecatedFault, TypeAlreadyExistsFault, UnknownResourceFault), which were
verified unchanged in the same probe.

Also adds integration coverage for the five actions that had none at either
test layer: DeprecateActivityType, UndeprecateActivityType, DeleteActivityType,
ListWorkflowTypes, and RespondActivityTaskFailed. Every assertion is taken from
a live-service capture, including that scheduling a deprecated activity type
appends ScheduleActivityTaskFailed with cause ACTIVITY_TYPE_DEPRECATED and
leaves the execution open, that ListWorkflowTypes filters by registration
status and name, and that a second RespondActivityTaskFailed on the same token
reports "Unknown activity, scheduledEventId = 5".

The message tests fail on the previous behaviour with "Expected: The type is
currently registered ... Actual: WorkflowType=[name=TestWf, version=1.0]".

Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
Andre Kurait committed 2026-08-12 21:37:31 +00:00
1 parent 43cdb1a482
commit 336dbe1cf8
3 files changed
+233 -9

No files matched your search

@@ -82,14 +82,14 @@ final class SwfFaults {
"ActivityType=[name=" + name + ", version=" + version + "]");
}
static AwsException workflowTypeNotDeprecated(String name, String version) {
/**
* Raised by DeleteWorkflowType/DeleteActivityType before the type is deprecated. Unlike
* the other type faults, the live service answers with prose rather than the type
* descriptor, and uses the same wording for both workflow and activity types.
*/
static AwsException typeNotDeprecated() {
return fault(SwfConstants.TYPE_NOT_DEPRECATED,
"WorkflowType=[name=" + name + ", version=" + version + "]");
}
static AwsException activityTypeNotDeprecated(String name, String version) {
return fault(SwfConstants.TYPE_NOT_DEPRECATED,
"ActivityType=[name=" + name + ", version=" + version + "]");
"The type is currently registered and cannot be deleted in its current state");
}
/**
@@ -246,7 +246,7 @@ public class SwfService implements Resettable {
requireDomain(domainName);
SwfWorkflowType type = findWorkflowType(domainName, name, version);
if (!type.isDeprecated()) {
throw SwfFaults.workflowTypeNotDeprecated(name, version);
throw SwfFaults.typeNotDeprecated();
}
workflowTypeStore.delete(typeKey(domainName, name, version));
}
@@ -325,7 +325,7 @@ public class SwfService implements Resettable {
requireDomain(domainName);
SwfActivityType type = findActivityType(domainName, name, version);
if (!type.isDeprecated()) {
throw SwfFaults.activityTypeNotDeprecated(name, version);
throw SwfFaults.typeNotDeprecated();
}
activityTypeStore.delete(typeKey(domainName, name, version));
}
@@ -14,6 +14,7 @@ import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
@@ -939,6 +940,229 @@ class SwfIntegrationTest {
equalTo(childStartedEventId));
}
@Test
void activityTypeDeprecationLifecycle_blocksSchedulingAndGatesDeletion() {
String domain = uniqueName("act-lifecycle");
registerDomain(domain);
registerWorkflowType(domain, "TestWf", "1.0");
registerActivityType(domain, "TestAct", "1.0");
call("DeprecateActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
// Deprecating twice reports the type descriptor, not prose.
call("DeprecateActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#TypeDeprecatedFault"))
.body("message", equalTo("ActivityType=[name=TestAct, version=1.0]"));
// A deprecated type stays describable and is listed under DEPRECATED.
call("DescribeActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(200)
.body("typeInfo.status", equalTo("DEPRECATED"))
.body("typeInfo.deprecationDate", notNullValue());
call("ListActivityTypes", """
{"domain": "%s", "registrationStatus": "DEPRECATED"}
""".formatted(domain))
.then()
.statusCode(200)
.body("typeInfos.activityType.name", hasItem("TestAct"));
// Scheduling a deprecated type fails the decision rather than the request.
startExecution(domain, "wf-dep-act", null);
String token = pollDecisionToken(domain);
call("RespondDecisionTaskCompleted", """
{"taskToken": "%s", "decisions": [
{"decisionType": "ScheduleActivityTask",
"scheduleActivityTaskDecisionAttributes": {
"activityId": "a1",
"activityType": {"name": "TestAct", "version": "1.0"}
}}]}
""".formatted(token)).then().statusCode(200);
call("DescribeWorkflowExecution", """
{"domain": "%s", "execution": {"workflowId": "wf-dep-act"}}
""".formatted(domain))
.then()
.body("executionInfo.executionStatus", equalTo("OPEN"));
call("GetWorkflowExecutionHistory", """
{"domain": "%s", "execution": {"workflowId": "wf-dep-act"}}
""".formatted(domain))
.then()
.body("events.find { it.eventType == 'ScheduleActivityTaskFailed' }"
+ ".scheduleActivityTaskFailedEventAttributes.cause",
equalTo("ACTIVITY_TYPE_DEPRECATED"));
// Delete is gated on deprecation, and reports prose rather than the descriptor.
call("UndeprecateActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
call("UndeprecateActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#TypeAlreadyExistsFault"));
call("DeleteActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#TypeNotDeprecatedFault"))
.body("message",
equalTo("The type is currently registered and cannot be deleted in its current state"));
call("DeprecateActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
call("DeleteActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
call("DescribeActivityType", """
{"domain": "%s", "activityType": {"name": "TestAct", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#UnknownResourceFault"))
.body("message", equalTo("Unknown type: ActivityType=[name=TestAct, version=1.0]"));
}
@Test
void deleteWorkflowType_isGatedOnDeprecationAndReportsProse() {
String domain = uniqueName("wf-delete");
registerDomain(domain);
registerWorkflowType(domain, "TestWf", "1.0");
call("DeleteWorkflowType", """
{"domain": "%s", "workflowType": {"name": "TestWf", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#TypeNotDeprecatedFault"))
.body("message",
equalTo("The type is currently registered and cannot be deleted in its current state"));
call("DeprecateWorkflowType", """
{"domain": "%s", "workflowType": {"name": "TestWf", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
call("DeleteWorkflowType", """
{"domain": "%s", "workflowType": {"name": "TestWf", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
call("DeleteWorkflowType", """
{"domain": "%s", "workflowType": {"name": "TestWf", "version": "1.0"}}
""".formatted(domain))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#UnknownResourceFault"))
.body("message", equalTo("Unknown type: WorkflowType=[name=TestWf, version=1.0]"));
}
@Test
void listWorkflowTypes_filtersByRegistrationStatusAndName() {
String domain = uniqueName("wf-list");
registerDomain(domain);
registerWorkflowType(domain, "Alpha", "1.0");
registerWorkflowType(domain, "Beta", "1.0");
call("ListWorkflowTypes", """
{"domain": "%s", "registrationStatus": "REGISTERED"}
""".formatted(domain))
.then()
.statusCode(200)
.body("typeInfos.workflowType.name", hasItem("Alpha"))
.body("typeInfos.workflowType.name", hasItem("Beta"))
.body("typeInfos[0].status", equalTo("REGISTERED"))
.body("typeInfos[0].creationDate", notNullValue());
call("ListWorkflowTypes", """
{"domain": "%s", "registrationStatus": "REGISTERED", "name": "Alpha"}
""".formatted(domain))
.then()
.body("typeInfos.size()", equalTo(1))
.body("typeInfos[0].workflowType.name", equalTo("Alpha"));
call("DeprecateWorkflowType", """
{"domain": "%s", "workflowType": {"name": "Alpha", "version": "1.0"}}
""".formatted(domain)).then().statusCode(200);
call("ListWorkflowTypes", """
{"domain": "%s", "registrationStatus": "DEPRECATED"}
""".formatted(domain))
.then()
.body("typeInfos.size()", equalTo(1))
.body("typeInfos[0].workflowType.name", equalTo("Alpha"));
call("ListWorkflowTypes", """
{"domain": "%s", "registrationStatus": "REGISTERED"}
""".formatted(domain))
.then()
.body("typeInfos.workflowType.name", not(hasItem("Alpha")))
.body("typeInfos.workflowType.name", hasItem("Beta"));
}
@Test
void respondActivityTaskFailed_recordsReasonAndDetailsThenClosesTheToken() {
String domain = uniqueName("act-fail");
registerDomain(domain);
registerWorkflowType(domain, "TestWf", "1.0");
registerActivityType(domain, "TestAct", "1.0");
String runId = startExecution(domain, "wf-act-fail", null);
String token = pollDecisionToken(domain);
call("RespondDecisionTaskCompleted", """
{"taskToken": "%s", "decisions": [
{"decisionType": "ScheduleActivityTask",
"scheduleActivityTaskDecisionAttributes": {
"activityId": "a-fail",
"activityType": {"name": "TestAct", "version": "1.0"}
}}]}
""".formatted(token)).then().statusCode(200);
String activityToken = call("PollForActivityTask", """
{"domain": "%s", "taskList": {"name": "floci-tl"}, "identity": "w"}
""".formatted(domain))
.then().statusCode(200)
.extract().path("taskToken");
call("RespondActivityTaskFailed", """
{"taskToken": "%s", "reason": "boom", "details": "stack trace here"}
""".formatted(activityToken)).then().statusCode(200);
call("GetWorkflowExecutionHistory", """
{"domain": "%s", "execution": {"workflowId": "wf-act-fail", "runId": "%s"}}
""".formatted(domain, runId))
.then()
.body("events.eventType", hasItem("ActivityTaskFailed"))
.body("events.find { it.eventType == 'ActivityTaskFailed' }"
+ ".activityTaskFailedEventAttributes.reason", equalTo("boom"))
.body("events.find { it.eventType == 'ActivityTaskFailed' }"
+ ".activityTaskFailedEventAttributes.details", equalTo("stack trace here"))
// A failed activity schedules a decision task so the decider can retry or fail.
.body("events[-1].eventType", equalTo("DecisionTaskScheduled"));
// The token is genuine but its task has closed, so the fault names the scheduled event.
call("RespondActivityTaskFailed", """
{"taskToken": "%s", "reason": "boom", "details": "again"}
""".formatted(activityToken))
.then()
.statusCode(400)
.body("__type", equalTo("com.amazonaws.swf.base.model#UnknownResourceFault"))
.body("message", equalTo("Unknown activity, scheduledEventId = 5"));
}
// ───────────────────────────── Counting and tags ─────────────────────────
@Test