fix(apps-engine): check installApp return value before initialization…#37487
fix(apps-engine): check installApp return value before initialization…#37487anandcomp22 wants to merge 6 commits intoRocketChat:developfrom
Conversation
|
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
WalkthroughAdds a public static Changes
Sequence DiagramsequenceDiagram
participant Caller
participant AppManager
participant installApp as installApp()
participant appMetadataStorage as appMetadataStorage
participant fulfillment as AppFabricationFulfillment
participant logger as Logger
Caller->>AppManager: add()
AppManager->>installApp: invoke
alt Installation Fails (returns false)
installApp-->>AppManager: false
AppManager->>logger: error("install failed")
AppManager->>appMetadataStorage: updateStatus(..., ERROR_DISABLED)
AppManager->>fulfillment: setStorageError(error)
AppManager-->>Caller: return (early)
else Installation Succeeds (returns true)
installApp-->>AppManager: true
AppManager->>AppManager: initializeApp()
AppManager->>AppManager: runStartUpProcess()
AppManager-->>Caller: complete
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-10-06T20:30:45.540ZApplied to files:
🔇 Additional comments (2)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit 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.
📒 Files selected for processing (1)
packages/apps-engine/src/server/AppManager.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-06T20:30:45.540Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 37152
File: packages/apps-engine/tests/test-data/storage/storage.ts:101-122
Timestamp: 2025-10-06T20:30:45.540Z
Learning: In `packages/apps-engine/tests/test-data/storage/storage.ts`, the stub methods (updatePartialAndReturnDocument, updateStatus, updateSetting, updateAppInfo, updateMarketplaceInfo) intentionally throw "Method not implemented." Tests using these methods must stub them using `SpyOn` from the test library rather than relying on actual implementations.
Applied to files:
packages/apps-engine/src/server/AppManager.ts
|
|
Hey, I've tried installing the app below and it was still successfully installed and enabled export class SlashcommanderApp extends App {
constructor(info: IAppInfo, logger: ILogger, accessors: IAppAccessors) {
super(info, logger, accessors);
}
public async onInstall(context: IAppInstallationContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise<void> {
throw new Error('What happens now?');
}
}I can see the error thrown in server logs Please review your implementation for it to match your intended behavior
|
… (#37472)
Proposed Changes
This pull request enhances error handling in the
AppManagerclass by verifying the outcome of theinstallApp()method before moving forward with app initialization.Previously, the
add()method overlooked the boolean return value frominstallApp(), allowing initialization to continue even if installation failed. This behavior could lead to inconsistencies and make it difficult to identify underlying installation issues.Key Changes
installApp()within theadd()function.AppManager.Issue(s)
Closes #37472
Steps to Test or Reproduce
ERROR_DISABLED, and a corresponding log entry clearly indicates the failure.Further Comments
This update makes sure that serious installation errors are properly caught instead of being overlooked.
It also keeps the error-handling process consistent with Rocket.Chat’s best practices for managing the app lifecycle.
Summary by CodeRabbit