Skip to content

Commit 81194d9

Browse files
authored
INTERNAL: ACSP-270 Validation Fixes (#57)
* refactor: don't include workspace config in errors * refactor: add hint on workspace config * chore: fix readme * refactor: add more hints * refactor: fix lint issue * test: fix test issues * refactor: add unsaved file
1 parent b05dfe1 commit 81194d9

9 files changed

Lines changed: 55 additions & 11 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Go to the [Adobe developer console](https://developer.adobe.com/console) portal
3434
- Adobe I/O Events for Adobe Commerce
3535
- Adobe Commerce as a Cloud Service.
3636
- If upgrading from previous versions without Adobe Commerce as a Cloud Service API:
37-
- Check ```.env``` to ensure that ```commerce.accs``` scope has been added to OAUTH_SCOPES
38-
- Download again workspace configuration as explained below and execute ```run aio app use``` again.
37+
- Check `.env` to ensure that `commerce.accs` scope has been added to `OAUTH_SCOPES`
38+
- Download again workspace configuration as explained below and execute `aio app use` again.
3939
- Download the [workspace configuration JSON](https://developer.adobe.com/commerce/extensibility/events/project-setup/#download-the-workspace-configuration-file) file and save it as `workspace.json` in the `./scripts/onboarding/config` starter kit folder because you will use it to configure Adobe IO Events in commerce afterward.
4040

4141
> [!TIP]

scripts/lib/configure-eventing.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ async function main (providerId, instanceId, workspaceConfiguration, environment
3838
success: true
3939
}
4040
} catch (error) {
41-
const hints = []
41+
const hints = [
42+
'Ensure your "onboarding/config/workspace.json" file is up to date',
43+
'Did you run `aio app deploy`? Your runtime actions should be deployed before running the onboarding script',
44+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL'
45+
]
4246

4347
if (error?.message?.includes('Response code 404 (Not Found)')) {
4448
hints.push('Make sure the latest version of the Adobe I/O Events module (see https://developer.adobe.com/commerce/extensibility/events/release-notes/) is installed and enabled in Commerce (see https://developer.adobe.com/commerce/extensibility/events/installation/).')
@@ -50,7 +54,7 @@ async function main (providerId, instanceId, workspaceConfiguration, environment
5054
'Unexpected error occurred while updating the eventing configuration of the Adobe I/O Events module in Commerce',
5155
{
5256
error,
53-
config: body.config,
57+
config: { ...body.config, workspace_configuration: undefined },
5458
hints: hints.length > 0 ? hints : undefined
5559
}
5660
)

scripts/lib/event-subscribe.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ async function main (eventSpec, environment) {
3232
} catch (error) {
3333
let label = 'UNEXPECTED_ERROR'
3434
let reason = 'Unexpected error occurred while subscribing to an event in the Adobe I/O Events module in Commerce'
35-
const hints = []
35+
const hints = [
36+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL'
37+
]
3638

3739
if (error?.message?.includes('Response code 400 (Bad Request)')) {
3840
label = 'MALFORMED_EVENT_SPEC'

scripts/lib/metadata.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,19 @@ async function main (clientRegistrations, providers, environment, accessToken) {
240240
result
241241
}
242242
} catch (error) {
243+
const hints = [
244+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL',
245+
'Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?'
246+
]
247+
243248
return makeError(
244249
'UNEXPECTED_ERROR',
245250
'Unexpected error occurred while adding metadata to provider',
246-
{ error, provider: currentProvider }
251+
{
252+
error,
253+
provider: currentProvider,
254+
hints: hints.length > 0 ? hints : undefined
255+
}
247256
)
248257
}
249258
}

scripts/lib/providers.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,19 @@ async function main (clientRegistrations, environment, accessToken) {
179179
console.log('Process of creating providers done successfully')
180180
return response
181181
} catch (error) {
182+
const hints = [
183+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL',
184+
'Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?'
185+
]
186+
182187
return makeError(
183188
'UNEXPECTED_ERROR',
184189
'Unexpected error occurred while creating providers',
185-
{ error, provider: currentProvider }
190+
{
191+
error,
192+
provider: currentProvider,
193+
hints: hints.length > 0 ? hints : undefined
194+
}
186195
)
187196
}
188197
}

scripts/lib/registrations.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,18 @@ async function main (clientRegistrations, providers, environment, accessToken) {
8080
registrations: result
8181
}
8282
} catch (error) {
83+
const hints = [
84+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL',
85+
'Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?'
86+
]
87+
8388
return makeError(
8489
'UNEXPECTED_ERROR',
8590
'Unexpected error occurred while creating registrations',
86-
{ error }
91+
{
92+
error,
93+
hints: hints.length > 0 ? hints : undefined
94+
}
8795
)
8896
}
8997
}

test/scripts/lib/onboarding.metadata.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ describe('Given on-boarding metadata file', () => {
163163
id: 'COMMERCE_PROVIDER_ID',
164164
key: 'commerce',
165165
label: 'Commerce Provider'
166-
}
166+
},
167+
hints: [
168+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL',
169+
'Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?'
170+
]
167171
}
168172
}
169173
})

test/scripts/lib/onboarding.providers.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,11 @@ describe('Given On-boarding providers file', () => {
11081108
reason: 'Unexpected error occurred while creating providers',
11091109
payload: {
11101110
error: fakeError,
1111-
provider: undefined
1111+
provider: undefined,
1112+
hints: [
1113+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL',
1114+
'Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?'
1115+
]
11121116
}
11131117
}
11141118
})

test/scripts/lib/onboarding.registrations.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,11 @@ describe('Given on-boarding registrations file', () => {
841841
label: 'UNEXPECTED_ERROR',
842842
reason: 'Unexpected error occurred while creating registrations',
843843
payload: {
844-
error: fakeError
844+
error: fakeError,
845+
hints: [
846+
'Make sure your authentication environment parameters are correct. Also check the COMMERCE_BASE_URL',
847+
'Did you fill IO_CONSUMER_ID, IO_PROJECT_ID and IO_WORKSPACE_ID environment variables with the values in /onboarding/config/workspace.json?'
848+
]
845849
}
846850
}
847851
})

0 commit comments

Comments
 (0)