[BUG] buildDefinition drops the whole type when one item fails validation, and --skipValidation cannot get past a broken .mcdev-validations.js
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
Research direction
Start with lib/Builder.js and compare _buildDefinition with _buildTemplate; then trace checkCustomRules in lib/util/validations.js and its call from lib/util/config.js. Add tests for a failing item beside a successful one, --skipValidation with an unloadable rules file and a throwing validation(), and non-Error thrown values. Done means good items finish and are reported, skip mode continues with warnings, and thrown values have readable messages.
Written by the indexing model from the issue text.
Description
Current Behavior
Two gaps in how custom validation rules (.mcdev-validations.js) are handled, found while reviewing #2752. Both found by reading the code on develop (10.3.1); not yet reproduced with a live run.
1. One failing item stops the whole build of its type
Builder._buildDefinition (lib/Builder.js) builds all items of a type in one Promise.all with a single catch around it. If validation fails for one item (a validation() that throws, or a rule set to error), then:
- the result list of that type is lost, even for the items that built fine, and
- mcdev stops waiting for the other items, which may still be writing files in the background. The command then reports a result that does not match what ended up on disk.
_buildTemplate in the same file already catches errors per item and skips only the failing one. #2752's description says build errors are caught per item, but _buildDefinition does not do that yet.
2. --skipValidation cannot get you past a broken .mcdev-validations.js
The option is meant as the way out when validation is in the way. Today:
- If
.mcdev-validations.jsexists but cannot be loaded (syntax error, wrong export),checkCustomRules(lib/util/validations.js, called fromlib/util/config.js) stops every command before any item is processed, with or without--skipValidation. - If the project's
validation()function throws for an item, that item is blocked, with or without--skipValidation. - Only single rules that fail or throw are downgraded to warnings by the flag.
So a project whose rules file is broken cannot retrieve, deploy or build at all until someone fixes that file.
Minor: error messages when validation() throws something that is not an Error: throw null gives "Cannot read properties of null", throw 'text' gives "undefined" instead of the thrown text.
Expected Behavior
buildDefinitionhandles each item on its own, likebuildTemplate: a failing item is logged and skipped, the other items are built and returned, and mcdev waits for all of them before it reports.- With
--skipValidation, a rules file that cannot be loaded and avalidation()that throws are logged as warnings and the command continues, the same way the flag already treats failing single rules. Without the flag the current strict behaviour stays. - Any thrown value gives a readable message (
String(ex?.message ?? ex)).
Steps To Reproduce
- Add
.mcdev-validations.jsand enableoptions.validation.buildDefinitionin.mcdevrc.json. - Make
validation()throw for one specific key only, then runmcdev bd <bu> -m <type>:<goodKey> -m <type>:<badKey>→ nothing is reported as built for the type. - Put a syntax error into
.mcdev-validations.js, then runmcdev retrieve <bu> -m <type> --skipValidation→ the command stops before retrieving.
Version
10.3.1
Additional comments
Tests should cover: one throwing item next to a good item in buildDefinition; --skipValidation with an unloadable rules file; --skipValidation with a throwing validation(); throw null / throw 'text' messages.
- Dominant language
- JavaScript
- Stars
- 166
- Forks
- 50
- Avg merge
- 11h 4m
- Merged PRs (30d)
- 36
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Accenture/sfmc-devtools
-
e/DevOps enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Accenture/sfmc-devtools#2795 ·
Maintainers usually reply within 1 day
-
c/INIT chore
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Accenture/sfmc-devtools#2793 ·
Maintainers usually reply within 1 day
-
bug c/automation
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Accenture/sfmc-devtools#2792 ·
Maintainers usually reply within 1 day
-
[FEATURE] transactionalPush: check options.customKeys against the app before deployPossibly taken @orshih6 claimed this 8 days ago. Openc/mobilePushApp c/transactionalPush enhancement
Difficulty 3/5 1-2 days Newbie friendliness 74/100
Accenture/sfmc-devtools#2735 ·
Maintainers usually reply within 1 day
-
c/mobileMessage c/mobilePush c/transactionalPush c/transactionalSms enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Accenture/sfmc-devtools#2733 ·
Maintainers usually reply within 1 day
All issues in Accenture/sfmc-devtools
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Life-Framework/Life-Framework#7017 ·
Maintainers usually reply within 1 day
-
agent/guide documentation help wanted stage/010-actionable
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kubestellar/console-kb#4003 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FilOzone/synapse-sdk#1201 · 1 comment ·
Maintainers usually reply within 1 day
-
good first issue task
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
NSC-Tech-Hub/nscth-static-website#107 ·
Maintainers usually reply within 1 day