-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Don't break when Appsmtih API URL isn't set #37309
Conversation
WalkthroughThis pull request introduces several new constants related to API URLs in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
app/client/packages/rts/src/middlewares/socket-auth.ts (1)
Line range hint
8-13
: Consider creating an issue to track the HTTPS endpoint debuggingThe TODO comment identifies a potential improvement to derive API_BASE_URL from the host header, but notes an Axios HTTPS issue blocking this enhancement.
Would you like me to create a GitHub issue to track the investigation of the Axios HTTPS endpoint issue?
app/client/packages/rts/src/test/server.test.ts (2)
Line range hint
14-119
: Consider organizing test cases using test.each()The entityRefactor array contains multiple similar test cases. Consider using Jest's test.each() for better test organization and maintenance.
Example refactor:
const testCases = [ { input: { script: "ApiNever", oldName: "ApiNever", newName: "ApiForever", isJSObject: false }, expected: { script: "ApiForever", refactorCount: 1 } }, // ... other cases ]; test.each(testCases)('Entity refactor: $input.script', async ({ input, expected }) => { const response = await supertest(app) .post(`${RTS_BASE_API_PATH}/ast/entity-refactor`) .send(input); expect(response.body.data.script).toEqual(expected.script); expect(response.body.data.refactorCount).toEqual(expected.refactorCount); });
Line range hint
234-252
: Consider adding more error test casesWhile the syntax error test is good, consider adding tests for:
- Invalid oldName/newName combinations
- Empty script strings
- Malformed input objects
Example additional test:
it("handles empty script input", async () => { const request = { script: "", oldName: "ApiNever", newName: "ApiForever", isJSObject: true }; await supertest(app) .post(`${RTS_BASE_API_PATH}/ast/entity-refactor`) .send(request) .expect(400); });
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (5)
app/client/packages/rts/src/constants/routes.ts
(1 hunks)app/client/packages/rts/src/middlewares/socket-auth.ts
(2 hunks)app/client/packages/rts/src/server.ts
(1 hunks)app/client/packages/rts/src/test/server.test.ts
(1 hunks)deploy/docker/fs/opt/appsmith/templates/docker.env.sh
(0 hunks)
💤 Files with no reviewable changes (1)
- deploy/docker/fs/opt/appsmith/templates/docker.env.sh
✅ Files skipped from review due to trivial changes (1)
- app/client/packages/rts/src/constants/routes.ts
🔇 Additional comments (6)
app/client/packages/rts/src/server.ts (3)
15-15
: LGTM! Good centralization of route constants.
Moving route constants to a central location improves maintainability.
Line range hint 44-45
: LGTM! Appropriate timeout settings.
The headersTimeout (61s) being slightly higher than keepAliveTimeout (60s) follows best practices for preventing race conditions in connection handling.
15-15
: Verify default API URL handling in routes.ts
The removal of API_BASE_URL error handling assumes that routes.ts provides appropriate defaults. Let's verify this assumption.
app/client/packages/rts/src/middlewares/socket-auth.ts (2)
5-5
: LGTM! Good move to centralize API URL configuration
The change to import BASE_APPSMITH_API_URL from routes constants aligns well with reducing environment variable dependencies.
38-38
: Verify the BASE_APPSMITH_API_URL constant definition
Let's ensure the constant is properly defined with the correct default value.
app/client/packages/rts/src/test/server.test.ts (1)
1-2
: LGTM: Import refactor aligns with centralization goal
The change to import RTS_BASE_API_PATH from @constants/routes improves code organization.
We actually don't need the `APPSMITH_API_BASE_URL` variable to be varying in production ever at all, and the `routes.ts` file already does have a default for this (on EE). Let's just use that instead of throwing an impact-less error. Ideally though, we shouldn't have this env variable at all. Less things that are configurable, less things that can break other things. ## Automation /test sanity ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11812221529> > Commit: f049d46 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11812221529&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Wed, 13 Nov 2024 07:41:57 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes - **New Features** - Introduced constants for API URLs to streamline endpoint configurations. - **Bug Fixes** - Updated API request URLs to use new constants, ensuring consistency across the application. - **Refactor** - Centralized route constants to improve maintainability. - Renamed entities in test cases for clarity while preserving functionality. - **Chores** - Removed obsolete environment variable related to API base URL from the Docker configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
We actually don't need the
APPSMITH_API_BASE_URL
variable to be varying in production ever at all, and theroutes.ts
file already does have a default for this (on EE). Let's just use that instead of throwing an impact-less error.Ideally though, we shouldn't have this env variable at all. Less things that are configurable, less things that can break other things.
Automation
/test sanity
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11812221529
Commit: f049d46
Cypress dashboard.
Tags:
@tag.Sanity
Spec:
Wed, 13 Nov 2024 07:41:57 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Refactor
Chores