🐛 New settings fail to override existing settings when loading template
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- cli
Research direction
Start in load-settings.ts and inspect mergeJsonStrings and loadSettings, focusing on the order of current database settings and incoming template settings passed to customDefu. Reproduce the issue by loading the simple-cms template into an empty Directus project. Done means project_name and project_color from the template override conflicting existing values while mergeArrays remains additive and duplicate-free.
Written by the indexing model from the issue text.
Description
I discovered a bug in the load-settings.ts file where new settings from configuration files fail to properly override existing settings in the database. This occurs because the parameter order in the mergeJsonStrings function and loadSettings function incorrectly prioritizes existing values over new ones.
Current behavior
Currently in load-settings.ts:
function mergeJsonStrings(current: string, incoming: string): string {
try {
return JSON.stringify(customDefu(JSON.parse(current), JSON.parse(incoming)))
} catch {
return incoming // If not valid JSON, return the incoming value
}
}
And in the main function:
const mergedSettings = customDefu(currentSettings, settings) as DirectusSettings
With the customDefu function, the second parameter should override the first. However, in these implementations, the current values (from the database) are being given precedence over the incoming values (from the new settings file).
Expected behavior
When loading settings, new configuration values from the settings file should override existing values in the database when there are conflicts.
Additional notes
The mergeArrays function doesn't seem to have this issue. It seems to be intentionally designed to be additive while avoiding duplicates.
Reproduction steps
If you would load an empty directus project, and apply the simple-cms template it would not update the project_name and project_color properly.
- Dominant language
- TypeScript
- Stars
- 191
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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 directus-labs/directus-template-cli
-
BSL to MSCL Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
directus-labs/directus-template-cli#144 · 2 comments · 3 reactions ·
-
Strip out project id OpenBug
directus-labs/directus-template-cli#124 · 1 comment · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
directus-labs/directus-template-cli#103 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
directus-labs/directus-template-cli#94 · 8 comments ·
All issues in directus-labs/directus-template-cli
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100