Description
When running a0deploy export with AUTH0_PRESERVE_KEYWORDS: true in the config, the export crashes:
error: Problem running command export
error: Problem loading tenant data from Auth0 TypeError: Cannot read properties of undefined (reading 'flat')
Root cause
In lib/keywordPreservation.js:167:
const resourceSpecificIdentifiers = auth0Handlers.reduce((acc, handler) => {
acc[handler.type] = handler.identifiers.flat(); // crashes here
return acc;
}, {});
The clientAuthCredentialsPre handler (a deploy-only pre-pass handler registered in lib/tools/auth0/handlers/index.js:129 via ...{ clientAuthCredentialsPre }) sets this.type = 'clientAuthCredentials' (in clientAuthCredentialsPre.js:37) but never sets this.identifiers and does not extend any base class that would set it. Therefore handler.identifiers is undefined, and calling .flat() on it throws.
The 8.42.0 release (#1438) fixed a dry-run crash on clientAuthCredentials, but the export path through preserveKeywords is a separate code path that remains unfixed.
Suggested fix
Option A — guard against undefined identifiers:
acc[handler.type] = (handler.identifiers || []).flat();
Option B — skip handlers without identifiers:
if (handler.identifiers === undefined) return acc;
acc[handler.type] = handler.identifiers.flat();
Reproduction
- Use any config JSON with
"AUTH0_PRESERVE_KEYWORDS": true
- Run
a0deploy export -c config.json --format=yaml --output_folder=./out
- Observe crash
The crash occurs during handler iteration in preserveKeywords, before any tenant-specific data matters, so any tenant with keyword preservation enabled will trigger it.
Versions affected
Versions not affected
- 8.39.0 and earlier (the
clientAuthCredentialsPre handler did not exist yet; all handlers had identifiers set)
Minimal reproduction across versions
| Version |
Result |
| 8.39.0 |
passes (no clientAuthCredentialsPre handler) |
| 8.40.0+ |
crashes (handler exists, identifiers undefined) |
Description
When running
a0deploy exportwithAUTH0_PRESERVE_KEYWORDS: truein the config, the export crashes:Root cause
In
lib/keywordPreservation.js:167:The
clientAuthCredentialsPrehandler (a deploy-only pre-pass handler registered inlib/tools/auth0/handlers/index.js:129via...{ clientAuthCredentialsPre }) setsthis.type = 'clientAuthCredentials'(inclientAuthCredentialsPre.js:37) but never setsthis.identifiersand does not extend any base class that would set it. Thereforehandler.identifiersisundefined, and calling.flat()on it throws.The 8.42.0 release (#1438) fixed a dry-run crash on
clientAuthCredentials, but the export path throughpreserveKeywordsis a separate code path that remains unfixed.Suggested fix
Option A — guard against undefined identifiers:
Option B — skip handlers without identifiers:
Reproduction
"AUTH0_PRESERVE_KEYWORDS": truea0deploy export -c config.json --format=yaml --output_folder=./outThe crash occurs during handler iteration in
preserveKeywords, before any tenant-specific data matters, so any tenant with keyword preservation enabled will trigger it.Versions affected
clientAuthCredentialsPre)Versions not affected
clientAuthCredentialsPrehandler did not exist yet; all handlers hadidentifiersset)Minimal reproduction across versions
clientAuthCredentialsPrehandler)identifiersundefined)