Skip to content

Conversation

@vednarvekar
Copy link

@vednarvekar vednarvekar commented Jan 6, 2026

Proposed changes

This PR fixes a control-flow issue in the Apps Engine where app initialization could continue even when installApp fails.

Previously, the return value of installApp was ignored, allowing the startup or initialization process to run despite a failed installation. This could leave the app in an inconsistent or partially-initialized state.

Issue

#37472

What’s changed

  • Capture the boolean result of installApp
  • Stop execution early and return an error response when installation fails
  • Ensure startup/initialization only runs for successfully installed apps

Why this matters

  • Prevents invalid app states
  • Aligns runtime behavior with installation outcome
  • Improves reliability and error handling during app installation

No behavior changes occur for successful installations, and no additional side effects are introduced.

Summary by CodeRabbit

  • Bug Fixes
    • Improved app installation flow: failed installations now set a clear storage error, roll back partial changes, and prevent apps from starting or initializing when installation does not complete successfully, improving stability during app add operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2026

⚠️ No Changeset found

Latest commit: 9f9b9b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 6, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Walkthrough

AppManager.add now captures the boolean result of installApp(app, user); on false it writes a storage error ("App installation failed") and returns early. On true it proceeds with the existing behavior: runStartUpProcess when enabled or initializeApp when disabled.

Changes

Cohort / File(s) Summary
AppManager installation validation
packages/apps-engine/src/server/AppManager.ts
Store installApp(app, user) result in a variable; if false, persist a storage error ("App installation failed") and return early. If true, continue to runStartUpProcess (when enabled) or initializeApp (when disabled).

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Client
    participant AppManager
    participant Installer as installApp()
    participant Storage
    participant Runtime as runStartUpProcess/initializeApp

    Note over AppManager,Installer: Add app flow
    Client->>AppManager: add(app, user, enable)
    AppManager->>Installer: installApp(app, user)
    alt install succeeded (true)
        Installer-->>AppManager: true
        AppManager->>Runtime: runStartUpProcess(app) / initializeApp(app)
        Runtime-->>AppManager: success
        AppManager-->>Client: return (success)
    else install failed (false)
        Installer-->>AppManager: false
        AppManager->>Storage: storeError("App installation failed")
        AppManager-->>Client: return (early)
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • ggazzo
  • sampaiodiego

Poem

🐇 I hopped in to check each app's start,
I asked installApp to play its part,
If it stumbled, I left a note,
If it leapt, I let it float,
A careful rabbit guards the mart.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main fix: preventing initialization when app installation fails, which is the core control-flow issue being addressed in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3ebe075 and 315c07c.

📒 Files selected for processing (1)
  • packages/apps-engine/src/server/AppManager.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/apps-engine/src/server/AppManager.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vednarvekar vednarvekar marked this pull request as ready for review January 6, 2026 09:27
@vednarvekar vednarvekar requested a review from a team as a code owner January 6, 2026 09:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI Agents
In @packages/apps-engine/src/server/AppManager.ts:
- Around line 645-649: The conditional block using enable with calls to
runStartUpProcess(created, app, false) and initializeApp(app) mixes tabs and
spaces; normalize the indentation to use consistent spaces (or the repo's
configured indent style) for the entire block and ensure the statements remain
exactly as runStartUpProcess(created, app, false) in the true branch and await
this.initializeApp(app) in the else branch so behavior is unchanged.
- Around line 638-641: The if-block in AppManager.ts has mixed tabs and spaces
around the installation failure handling (the condition checking the local
variable `installed`, the call to `aff.setStorageError('App installation
failed')`, and `return aff`), causing inconsistent indentation; fix it by
normalizing the indentation to match the project's style (convert the tabbed
lines to spaces or vice versa to match surrounding lines) for the block
containing `if (!installed) {`, `aff.setStorageError(...)`, and `return aff` so
the three lines use the same indentation characters and width.
🧹 Nitpick comments (1)
packages/apps-engine/src/server/AppManager.ts (1)

643-644: Remove implementation comments.

As per coding guidelines, avoid code comments in the implementation.

🔎 Proposed fix
-		// Should enable === true, then we go through the entire start up process
-		// Otherwise, we only initialize it.
 		if (enable) {
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d3511ea and 2274b7f.

📒 Files selected for processing (1)
  • packages/apps-engine/src/server/AppManager.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/apps-engine/src/server/AppManager.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: cubic · AI code reviewer
🔇 Additional comments (1)
packages/apps-engine/src/server/AppManager.ts (1)

636-637: LGTM - Installation result properly captured.

The boolean result from installApp is correctly captured for validation before proceeding with startup/initialization.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/apps-engine/src/server/AppManager.ts">

<violation number="1" location="packages/apps-engine/src/server/AppManager.ts:638">
P1: Missing cleanup when installation fails. Other error cases in this method call `undoSteps` to clean up resources (app package, runtime, app user). Returning without cleanup may leave the system in an inconsistent state.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.68%. Comparing base (00b36c5) to head (9f9b9b8).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38070      +/-   ##
===========================================
- Coverage    70.71%   70.68%   -0.03%     
===========================================
  Files         3142     3142              
  Lines       108819   108820       +1     
  Branches     19609    19578      -31     
===========================================
- Hits         76949    76919      -30     
- Misses       29869    29897      +28     
- Partials      2001     2004       +3     
Flag Coverage Δ
e2e 60.30% <ø> (-0.04%) ⬇️
e2e-api 48.06% <ø> (-1.03%) ⬇️
unit 71.76% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@d-gubert
Copy link
Member

@vednarvekar did you manage to cause the installApp to return false? Testing your PR I can't make that behavior happen

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.

2 participants