Skip to content

Commit 1f594d7

Browse files
#2454: show error during deploy if the key of an item exceed the max length
1 parent 56f6ba4 commit 1f594d7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/metadataTypes/MetadataType.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,19 @@ class MetadataType {
753753
return false;
754754
}
755755

756+
/**
757+
* helper for {@link MetadataType.upsert} to enforce max key length
758+
*
759+
* @param {string} metadataKey key of metadata
760+
*/
761+
static enforceMaxKeyLength(metadataKey) {
762+
if (this.definition.maxKeyLength && metadataKey.length > this.definition.maxKeyLength) {
763+
throw new Error(
764+
`key exceeds maximum length of ${this.definition.maxKeyLength} characters for this type`
765+
);
766+
}
767+
}
768+
756769
/**
757770
* MetadataType upsert, after retrieving from target and comparing to check if create or update operation is needed.
758771
*
@@ -774,6 +787,7 @@ class MetadataType {
774787
// preDeployTasks parsing
775788
let deployableMetadata;
776789
try {
790+
this.enforceMaxKeyLength(metadataKey);
777791
metadataMap[metadataKey] = await this.validation(
778792
'deploy',
779793
metadataMap[metadataKey],

0 commit comments

Comments
 (0)