fix(devcontainer): add robust error handling to post-create.sh#27203
fix(devcontainer): add robust error handling to post-create.sh#27203oluies wants to merge 1 commit intoopen-metadata:mainfrom
Conversation
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
| cd "$UI_DIR" | ||
| yarn install --frozen-lockfile || { echo "ERROR: yarn install failed"; exit 1; } | ||
| cd - |
There was a problem hiding this comment.
💡 Edge Case: cd - runs even if yarn succeeds but leaves wrong dir on error path
If yarn install succeeds, cd - returns to the previous directory, but its own failure is not checked. More importantly, if the script is later extended between cd and cd -, any intermediate failure could leave the shell in the wrong directory.
A safer pattern is to run yarn in a subshell so the directory change is automatically scoped:
(cd "$UI_DIR" && yarn install --frozen-lockfile) || { echo "ERROR: yarn install failed"; exit 1; }This avoids relying on cd - entirely.
Suggested fix:
Replace the cd / yarn / cd - block with a subshell:
(cd "$UI_DIR" && yarn install --frozen-lockfile) || { echo "ERROR: yarn install failed"; exit 1; }
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsDevcontainer post-create script now includes robust error handling for setup commands. Consider adding error checking for the 💡 Edge Case:
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Gitar
Describe your changes:
Fixes N/A
I worked on
.devcontainer/dev/post-create.shbecause the previous script lacked sufficient error handling, which made it difficult to diagnose why the development environment setup was failing during thepostCreateCommandexecution.Changes made:
yarn install.yarn installfailures.venvcreation andpipupgrades.makecommands (install_dev,generate, andprerequisites).How I tested my changes:
yarnormake) will now trigger a clearERROR:message in the logs instead of failing silently or with generic shell errors./tmp/post-create.logif the command fails to see the new detailed error output.Type of change:
Checklist:
Fixes <issue-number>: <short explanation>