Skip to content

Commit e086fe2

Browse files
witness-meVlad Nikolaenkohayemaxi
authored
feat(stepfunctions): allow starting execution with no input provided (aws#6708)
## Problem 1. Currently when customer starts step function execution with no input provided, they execution fails to start because of the blank input. It's not intuitive why it failed and error message is not very descriptive. 2. Multiple SFN localization strings are missing in `package.nls.json` 3. Blank lines added after SFN outputs are misleading and may imply that the process is not completed yet ## Solution 1. Allow starting execution with blank input - in that case we provide empty object as an input. Also improving error message wording to be more clear 2. Adding missing SFN strings to `package.nls.json` 3. Adding empty line only before logging command outputs. This way there is still a clear separation but no misleading empty line at the end --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Vlad Nikolaenko <[email protected]> Co-authored-by: Maxim Hayes <[email protected]>
1 parent 22d5a8a commit e086fe2

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

packages/core/package.nls.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
2323
"AWS.configuration.description.featureDevelopment.allowRunningCodeAndTests": "Allow /dev to run code and test commands",
2424
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.",
25+
"AWS.stepFunctions.publishStateMachine.error.invalidYAML": "Cannot publish invalid YAML file",
26+
"AWS.stepFunctions.publishStateMachine.info.creating": "Creating state machine '{0}' in {1}...",
27+
"AWS.stepFunctions.publishStateMachine.info.createSuccess": "Created state machine '{0}'",
28+
"AWS.stepFunctions.publishStateMachine.error.createFailure": "Failed to create state machine: {0}",
29+
"AWS.stepFunctions.publishStateMachine.info.updating": "Updating state machine '{0}' in {1}...",
30+
"AWS.stepFunctions.publishStateMachine.info.updateSuccess": "Updated state machine '{0}'",
31+
"AWS.stepFunctions.publishStateMachine.error.updateFailure": "Failed to update state machine: {0}",
32+
"AWS.stepFunctions.executeStateMachine.info.executing": "Starting execution of '{0}' in {1}...",
33+
"AWS.stepFunctions.executeStateMachine.info.started": "Execution started",
34+
"AWS.stepFunctions.executeStateMachine.error.failedToStart": "There was an error starting execution for '{0}', check AWS Toolkit logs for more information.",
2535
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
2636
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
2737
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",

packages/core/src/stepFunctions/commands/publishStateMachine.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function publishStateMachine(
4242
text = JSON.stringify(load(text), undefined, ' ')
4343
} catch (error) {
4444
const localizedMsg = localize(
45-
'AWS.message.error.stepFunctions.publishStateMachine.invalidYAML',
45+
'AWS.stepFunctions.publishStateMachine.error.invalidYAML',
4646
'Cannot publish invalid YAML file'
4747
)
4848

@@ -80,9 +80,10 @@ async function createStateMachine(
8080
const logger: Logger = getLogger()
8181
logger.info(`Creating state machine '${wizardResponse.name}'`)
8282
outputChannel.show()
83+
outputChannel.appendLine('')
8384
outputChannel.appendLine(
8485
localize(
85-
'AWS.message.info.stepFunctions.publishStateMachine.creating',
86+
'AWS.stepFunctions.publishStateMachine.info.creating',
8687
"Creating state machine '{0}' in {1}...",
8788
wizardResponse.name,
8889
region
@@ -96,23 +97,21 @@ async function createStateMachine(
9697
})
9798
outputChannel.appendLine(
9899
localize(
99-
'AWS.message.info.stepFunctions.publishStateMachine.createSuccess',
100-
'Created state machine "{0}"',
100+
'AWS.stepFunctions.publishStateMachine.info.createSuccess',
101+
"Created state machine '{0}'",
101102
wizardResponse.name
102103
)
103104
)
104105
outputChannel.appendLine(result.stateMachineArn)
105106
logger.info(`Created "${result.stateMachineArn}"`)
106-
outputChannel.appendLine('')
107107
} catch (err) {
108108
const msg = localize(
109-
'AWS.message.error.stepFunctions.publishStateMachine.createFailure',
109+
'AWS.stepFunctions.publishStateMachine.error.createFailure',
110110
'Failed to create state machine: {0}',
111111
wizardResponse.name
112112
)
113113
void showViewLogsMessage(msg)
114114
outputChannel.appendLine(msg)
115-
outputChannel.appendLine('')
116115
logger.error(`Failed to create state machine '${wizardResponse.name}': %O`, err as Error)
117116
}
118117
}
@@ -127,9 +126,10 @@ async function updateStateMachine(
127126
const logger: Logger = getLogger()
128127
logger.info(`Updating state machine ${wizardResponse.stateMachineArn}`)
129128
outputChannel.show()
129+
outputChannel.appendLine('')
130130
outputChannel.appendLine(
131131
localize(
132-
'AWS.message.info.stepFunctions.publishStateMachine.updating',
132+
'AWS.stepFunctions.publishStateMachine.info.updating',
133133
"Updating state machine '{0}' in {1}...",
134134
wizardResponse.stateMachineArn,
135135
region
@@ -142,22 +142,20 @@ async function updateStateMachine(
142142
})
143143
outputChannel.appendLine(
144144
localize(
145-
'AWS.message.info.stepFunctions.publishStateMachine.updateSuccess',
145+
'AWS.stepFunctions.publishStateMachine.info.updateSuccess',
146146
'Updated state machine: {0}',
147147
wizardResponse.stateMachineArn
148148
)
149149
)
150150
logger.info(`Updated ${wizardResponse.stateMachineArn}`)
151-
outputChannel.appendLine('')
152151
} catch (err) {
153152
const msg = localize(
154-
'AWS.message.error.stepFunctions.publishStateMachine.updateFailure',
153+
'AWS.stepFunctions.publishStateMachine.error.updateFailure',
155154
'Failed to update state machine: {0}',
156155
wizardResponse.stateMachineArn
157156
)
158157
void showViewLogsMessage(msg)
159158
outputChannel.appendLine(msg)
160-
outputChannel.appendLine('')
161159
logger.error(`Failed to update state machine '${wizardResponse.stateMachineArn}': %O`, err as Error)
162160
}
163161
}

packages/core/src/stepFunctions/vue/executeStateMachine/executeStateMachine.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ export class ExecuteStateMachineWebview extends VueWebview {
4444
this.logger.info('Starting Step Functions State Machine execution')
4545

4646
this.channel.show()
47+
this.channel.appendLine('')
4748
this.channel.appendLine(
4849
localize(
49-
'AWS.message.info.stepFunctions.executeStateMachine.executing',
50-
'Executing {0} in {1}...',
50+
'AWS.stepFunctions.executeStateMachine.info.executing',
51+
'Starting execution of {0} in {1}...',
5152
this.stateMachine.name,
5253
this.stateMachine.region
5354
)
@@ -58,22 +59,19 @@ export class ExecuteStateMachineWebview extends VueWebview {
5859
const client = new DefaultStepFunctionsClient(this.stateMachine.region)
5960
const startExecResponse = await client.executeStateMachine(this.stateMachine.arn, input)
6061
this.logger.info('started execution for Step Functions State Machine')
61-
this.channel.appendLine(
62-
localize('AWS.message.info.stepFunctions.executeStateMachine.started', 'Execution started')
63-
)
62+
this.channel.appendLine(localize('AWS.stepFunctions.executeStateMachine.info.started', 'Execution started'))
6463
this.channel.appendLine(startExecResponse.executionArn)
6564
} catch (e) {
6665
executeResult = 'Failed'
6766
const error = e as Error
6867
this.logger.error('Error starting execution for Step Functions State Machine: %s', error)
6968
this.channel.appendLine(
7069
localize(
71-
'AWS.message.error.stepFunctions.executeStateMachine.failed_to_start',
72-
'There was an error starting execution for {0}, check logs for more information.',
70+
'AWS.stepFunctions.executeStateMachine.error.failedToStart',
71+
'There was an error starting execution for {0}, check AWS Toolkit logs for more information.',
7372
this.stateMachine.arn
7473
)
7574
)
76-
this.channel.appendLine('')
7775
} finally {
7876
telemetry.stepfunctions_executeStateMachine.emit({ result: executeResult })
7977
}

packages/core/src/stepFunctions/vue/executeStateMachine/executeStateMachine.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ export default defineComponent({
101101
// const self = this
102102
if (inputFile.files && inputFile.files.length > 0) {
103103
const reader = new FileReader()
104-
reader.onload = event => {
104+
reader.onload = (event) => {
105105
if (event.target) {
106106
const result = event.target.result
107107
this.executionInput = result as string
108108
}
109109
} // desired file content
110-
reader.onerror = error => {
110+
reader.onerror = (error) => {
111111
throw error
112112
}
113113
reader.readAsText(inputFile.files[0])
@@ -116,7 +116,7 @@ export default defineComponent({
116116
}
117117
},
118118
sendInput: function () {
119-
client.executeStateMachine(this.executionInput)
119+
client.executeStateMachine(this.executionInput || '{}')
120120
},
121121
},
122122
mixins: [saveData],
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Step Functions: Allow starting state machine execution with no input provided"
4+
}

0 commit comments

Comments
 (0)