Skip to content

Conversation

@HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Nov 6, 2025

What does this PR do?

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • New Features

    • Hostname input now trims whitespace and defaults to "localhost" when left empty; suggested hostname tags remain available.
    • Hostname is always included when creating a web platform to ensure consistent submissions.
  • Bug Fixes

    • Validation now runs against the final, trimmed hostname to reduce false validation errors and improve form reliability.

@appwrite
Copy link

appwrite bot commented Nov 6, 2025

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

You can use Avatars API to generate QR code for any text or URLs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Walkthrough

The PR modifies a single Svelte component for creating a web platform. Hostname input is trimmed and a derived finalHostname defaults to "localhost" when empty; validation now runs against that finalHostname using a precompiled hostname regex. The payload sent to createPlatform always uses finalHostname (previously an empty hostname could yield undefined). The control flow still returns early if a hostname validation error is present. Minor markup reformatting around InputText/Fieldset closing tags was applied; no exported/public API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify trimming and defaulting of hostname (empty -> "localhost") behaves as intended.
  • Confirm validation uses the derived finalHostname and the regex matches the desired hostname rules.
  • Ensure the platform creation payload consistently sends finalHostname.
  • Check the small markup changes (InputText/Fieldset closing tags) for any rendering issues.

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 'feat: hostname is now optional with a default, not required' accurately summarizes the main change: hostname validation refactoring to make it optional with 'localhost' as default instead of required.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-SER-484-Make-hostname-required

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aea5fe4 and bf983f1.

📒 Files selected for processing (1)
  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (3 hunks)
⏰ 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). (2)
  • GitHub Check: build
  • GitHub Check: e2e
🔇 Additional comments (2)
src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (2)

176-176: LGTM! Correctly uses the normalized hostname.

Using finalHostname ensures the API always receives a valid hostname ('localhost' when empty), preventing undefined or empty values.


161-163: The review comment contains incorrect assumptions and should be disregarded.

The verification reveals that extendedHostnameRegex is a string pattern (defined with String.raw), not a compiled RegExp object. Therefore, the new RegExp() wrapper at line 161 is necessary and correct. The suggested fix would fail at runtime because strings don't have a .test() method—only RegExp objects do.

The hostname validation logic in lines 161-163 is correctly implemented as written.

Likely an incorrect or invalid review comment.


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.

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (1)

165-169: Validation logic inconsistent with required attribute.

The required attribute makes hostname mandatory in the UI, but the validation logic at line 165 treats empty hostname as valid by setting hostnameError = null. This creates an inconsistency where:

  1. HTML5 validation requires the field (line 267)
  2. Custom validation allows empty values (line 165)
  3. The API call handles empty as optional (line 178)

If the HTML5 validation is bypassed, empty hostnames would pass validation and submit.

Consider either:

  1. Make hostname truly required: Update validation to always validate presence and format
  2. Keep hostname optional: Remove the required attribute

Apply this diff if hostname should be truly required:

-    hostnameError = hostname !== '' ? !new RegExp(extendedHostnameRegex).test(hostname) : null;
+    hostnameError = !hostname || !new RegExp(extendedHostnameRegex).test(hostname);

And update line 178:

-    hostname: hostname === '' ? undefined : hostname
+    hostname: hostname

Also applies to: 267-267

🧹 Nitpick comments (2)
src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (2)

278-290: Consider icon semantics for hostname suggestions.

The IconPlus may be semantically unclear—clicking a tag selects/applies the value rather than adding something new. Consider whether a checkmark or selection indicator would better communicate the action.


178-178: Empty string handling may be unnecessary with required field.

Since hostname is now required (line 267), this empty string check is likely unreachable during normal flow. However, if you keep hostname as optional (per my previous comment about validation inconsistency), this defensive check remains useful.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49bdca6 and 23741c9.

📒 Files selected for processing (1)
  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (5 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-09-30T07:41:06.679Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2425
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:454-468
Timestamp: 2025-09-30T07:41:06.679Z
Learning: In `src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte`, the column suggestions API (console.suggestColumns) has a maximum limit of 7 columns returned, which aligns with the initial placeholder count of 7 in customColumns.

Applied to files:

  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte
📚 Learning: 2025-09-08T13:20:47.308Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2316
File: src/routes/(console)/project-[region]-[project]/functions/create-function/deploy/+page.svelte:29-29
Timestamp: 2025-09-08T13:20:47.308Z
Learning: The Form.svelte component in the Appwrite console creates a FormContext with isSubmitting as writable(false) and expects consumers to work with Svelte writable stores, not plain booleans.

Applied to files:

  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte
📚 Learning: 2025-09-26T06:48:57.938Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2373
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:629-631
Timestamp: 2025-09-26T06:48:57.938Z
Learning: In the Appwrite console codebase using appwrite.io/pink-svelte, the Icon component automatically handles CSS variable names passed to its color prop by internally wrapping them with var(). Therefore, passing '--some-css-variable' as a string to the Icon color prop works correctly without needing to manually wrap it with var().

Applied to files:

  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte
📚 Learning: 2025-10-13T05:13:54.542Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2413
File: src/routes/(console)/project-[region]-[project]/databases/table.svelte:33-39
Timestamp: 2025-10-13T05:13:54.542Z
Learning: In Svelte 5, `import { page } from '$app/state'` provides a reactive state proxy that can be accessed directly (e.g., `page.params`), unlike the older `import { page } from '$app/stores'` which returns a readable store requiring the `$page` syntax for auto-subscription in components.

Applied to files:

  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte
⏰ 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). (2)
  • GitHub Check: e2e
  • GitHub Check: build
🔇 Additional comments (2)
src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (2)

14-15: LGTM! Imports are correctly added.

The new imports (Tag, IconJs, IconPlus) are properly utilized in the component.

Also applies to: 28-29


73-73: LGTM! Reasonable hostname suggestions for local development.

The suggested hostnames cover common localhost scenarios.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23741c9 and aea5fe4.

📒 Files selected for processing (1)
  • src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (3 hunks)
⏰ 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). (2)
  • GitHub Check: e2e
  • GitHub Check: build
🔇 Additional comments (1)
src/routes/(console)/project-[region]-[project]/overview/platforms/createWeb.svelte (1)

176-176: LGTM: API call correctly uses the validated hostname.

The platform creation payload now uses finalHostname, ensuring the API receives the validated, defaulted value rather than the raw (potentially empty) input. This change is consistent with the validation logic.

@HarshMN2345 HarshMN2345 changed the title feat: made hostname required option feat: hostname is now optional with a default, not required. Nov 10, 2025
Comment on lines 161 to 162
const trimmedHostname = hostname?.trim() || '';
const finalHostname = trimmedHostname !== '' ? trimmedHostname : 'localhost';
Copy link
Member

Choose a reason for hiding this comment

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

could simplify.

hostnameError = hostname !== '' ? !new RegExp(extendedHostnameRegex).test(hostname) : null;
const trimmedHostname = hostname?.trim() || '';
const finalHostname = trimmedHostname !== '' ? trimmedHostname : 'localhost';
hostnameError = !new RegExp(extendedHostnameRegex).test(finalHostname);
Copy link
Member

Choose a reason for hiding this comment

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

i think we can do direct test check here on extendedHostnameRegex.

@ItzNotABug ItzNotABug merged commit 52111d4 into main Nov 10, 2025
4 checks passed
@ItzNotABug ItzNotABug deleted the fix-SER-484-Make-hostname-required branch November 10, 2025 07:59
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.

3 participants