Skip to content
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: Fix env varibles in 404.html #37672

Merged
merged 1 commit into from
Nov 26, 2024
Merged

chore: Fix env varibles in 404.html #37672

merged 1 commit into from
Nov 26, 2024

Conversation

sharat87
Copy link
Member

@sharat87 sharat87 commented Nov 25, 2024

Environment variables in 404.html page aren't getting replaced with their values. This PR fixes that.

Automation

/test sanity

🔍 Cypress test results

Warning

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12005727044
Commit: 56b10fd
Cypress dashboard.
Tags: @tag.Sanity
Spec:
It seems like no tests ran 😔. We are not able to recognize it, please check workflow here.


Mon, 25 Nov 2024 08:48:10 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Improved dynamic retrieval of environment variables for better integration with environment-specific settings in the 404 error page.
    • Enhanced handling of HTML files, including the 404 page, during the configuration process.
  • Bug Fixes

    • Improved error handling for missing SSL certificates and custom domains.
  • Documentation

    • Updated logic for processing HTML files to ensure correct paths and configurations are applied.

Copy link
Contributor

coderabbitai bot commented Nov 25, 2024

Walkthrough

The changes involve updates to the 404.html file and the caddy-reconfigure.mjs script. In 404.html, the retrieval of environment variables for smartLookId and sentryDSN has been modified to use a templating syntax for improved dynamic configuration. In caddy-reconfigure.mjs, the function for finalizing HTML files has been renamed and expanded to process both index.html and 404.html, enhancing the handling of environment variables and SSL certificate checks.

Changes

File Path Change Summary
app/client/public/404.html Updated smartLookId and sentryDSN to use templating syntax for environment variables.
deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs Renamed finalizeIndexHtml to finalizeHtmlFiles and expanded its logic to process both HTML files. Added checks for custom domains and SSL certificates.

Possibly related PRs

Suggested reviewers

  • mohanarpit
  • nidhi-nair
  • pratapaprasanna

🌟 In the land of code, where changes take flight,
The 404 now shines, with variables bright.
From caddy to HTML, the updates align,
With templates and checks, all working just fine!
So here's to the tweaks, both clever and neat,
In the world of our app, they can't be beat! 🎉


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Nov 25, 2024
@sharat87 sharat87 added the ok-to-test Required label for CI label Nov 25, 2024
@sharat87 sharat87 marked this pull request as ready for review November 25, 2024 09:12
@sharat87 sharat87 requested a review from hetunandu November 25, 2024 09:12
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: 1

🧹 Outside diff range and nitpick comments (2)
app/client/public/404.html (2)

30-31: Consider adding error boundaries around analytics initialization

While the analytics setup is good, consider adding try-catch blocks around the initialization code to prevent any potential script errors from affecting the page functionality.

 if(smartLookId) {
+  try {
     window.smartlook||(function(d) {
       var o=smartlook=function(){ o.api.push(arguments)},h=d.getElementsByTagName('head')[0];
       var c=d.createElement('script');o.api=new Array();c.async=true;c.type='text/javascript';
       c.charset='utf-8';c.src='https://web-sdk.smartlook.com/recorder.js';h.appendChild(c);
     })(document);
     smartlook('init', smartLookId, { region: 'eu' });
     smartlook("track", "UserReached404");
+  } catch (e) {
+    console.warn('Failed to initialize analytics:', e);
+  }
 }

Also applies to: 34-49


Line range hint 94-101: Enhance refresh mechanism reliability

The current refresh implementation using history.back() might not work if there's no previous page. Consider these improvements:

 function refresh() {
-  history.back();
+  if (window.history.length > 1) {
+    history.back();
+  } else {
+    window.location.href = '/';
+  }
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b9ce30e and 56b10fd.

📒 Files selected for processing (2)
  • app/client/public/404.html (1 hunks)
  • deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs (2 hunks)
🔇 Additional comments (3)
app/client/public/404.html (1)

30-31: LGTM: Environment variable syntax updated correctly

The change to use Caddy's template syntax for environment variables is appropriate and aligns with the fix objective.

deploy/docker/fs/opt/appsmith/caddy-reconfigure.mjs (2)

228-228: LGTM! Function name accurately reflects its purpose.

The rename from finalizeIndexHtml to finalizeHtmlFiles better represents the function's expanded scope.


252-255: LGTM! Secure environment variable handling.

The regex pattern ensures only APPSMITH_ prefixed variables are processed, with appropriate fallbacks.

@sharat87 sharat87 merged commit 7a0f654 into release Nov 26, 2024
45 of 47 checks passed
@sharat87 sharat87 deleted the chore/env-vars-in-404 branch November 26, 2024 06:11
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 27, 2024
Environment variables in `404.html` page aren't getting replaced with
their values. This PR fixes that.


## Automation

/test sanity

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!WARNING]
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12005727044>
> Commit: 56b10fd
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12005727044&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: @tag.Sanity
> Spec: 
> It seems like **no tests ran** 😔. We are not able to recognize it,
please check <a
href="https://github.com/appsmithorg/appsmith/actions/runs/12005727044"
target="_blank">workflow here</a>.
> <hr>Mon, 25 Nov 2024 08:48:10 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

- **New Features**
- Improved dynamic retrieval of environment variables for better
integration with environment-specific settings in the 404 error page.
- Enhanced handling of HTML files, including the 404 page, during the
configuration process.

- **Bug Fixes**
- Improved error handling for missing SSL certificates and custom
domains.

- **Documentation**
- Updated logic for processing HTML files to ensure correct paths and
configurations are applied.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants