Skip to content

fix(devcontainer): add robust error handling to post-create.sh#27203

Open
oluies wants to merge 1 commit intoopen-metadata:mainfrom
oluies:fix/devcontainer-post-create-failure
Open

fix(devcontainer): add robust error handling to post-create.sh#27203
oluies wants to merge 1 commit intoopen-metadata:mainfrom
oluies:fix/devcontainer-post-create-failure

Conversation

@oluies
Copy link
Copy Markdown

@oluies oluies commented Apr 9, 2026

Describe your changes:

Fixes N/A

I worked on .devcontainer/dev/post-create.sh because the previous script lacked sufficient error handling, which made it difficult to diagnose why the development environment setup was failing during the postCreateCommand execution.

Changes made:

  • Added directory existence checks for the frontend UI path before running yarn install.
  • Added explicit error handling and exit codes for yarn install failures.
  • Added error handling for Python venv creation and pip upgrades.
  • Added error handling for make commands (install_dev, generate, and prerequisites).
  • Added descriptive error messages to identify exactly which stage of the setup process fails.

How I tested my changes:

  • Verified the script logic by reviewing the execution flow.
  • Ensured that any failure in a critical step (like yarn or make) will now trigger a clear ERROR: message in the logs instead of failing silently or with generic shell errors.
  • (Recommendation) Users should check /tmp/post-create.log if the command fails to see the new detailed error output.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

Comment on lines +59 to +61
cd "$UI_DIR"
yarn install --frozen-lockfile || { echo "ERROR: yarn install failed"; exit 1; }
cd -
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

@gitar-bot
Copy link
Copy Markdown

gitar-bot bot commented Apr 9, 2026

Code Review 👍 Approved with suggestions 0 resolved / 1 findings

Devcontainer post-create script now includes robust error handling for setup commands. Consider adding error checking for the cd - command to ensure the directory change succeeds when yarn install completes.

💡 Edge Case: cd - runs even if yarn succeeds but leaves wrong dir on error path

📄 .devcontainer/dev/post-create.sh:59-61

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; }
🤖 Prompt for agents
Code Review: Devcontainer post-create script now includes robust error handling for setup commands. Consider adding error checking for the `cd -` command to ensure the directory change succeeds when `yarn install` completes.

1. 💡 Edge Case: `cd -` runs even if yarn succeeds but leaves wrong dir on error path
   Files: .devcontainer/dev/post-create.sh:59-61

   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:
   ```bash
   (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; }

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant