Skip to content

(feat): auto-detect cli params to force non-interactive installer#11636

Open
abnegate wants to merge 1 commit into1.9.xfrom
feat-auto-detect-cli
Open

(feat): auto-detect cli params to force non-interactive installer#11636
abnegate wants to merge 1 commit into1.9.xfrom
feat-auto-detect-cli

Conversation

@abnegate
Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 25, 2026

📝 Walkthrough

Walkthrough

This change modifies the installation task initialization logic in a single file. A new private method hasExplicitCliParams() was introduced to detect CLI parameters (scanning $_SERVER['argv'] for --* flags excluding --interactive). The control flow for starting the web installer was updated to require three conditions: interactive mode enabled, console interactivity detected, and absence of explicit CLI parameters. Additionally, the self-hosted installation tracking payload field was renamed from hostIp to ip, maintaining the same value derivation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is an unfilled template with no actual content about the changes, test plan, or rationale for the PR. Fill in the PR description with details about what the changes accomplish, why they are needed, how to test them, and any related issues.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: auto-detecting CLI parameters to force the installer into non-interactive mode, which aligns with the actual code modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-auto-detect-cli

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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR adds auto-detection of explicit CLI parameters to force the installer into non-interactive (CLI) mode, bypassing the web installer when flags like --database or --http-port are provided. It also renames the hostIp field to ip in the Growth analytics payload.

  • The new hasExplicitCliParams() method uses an overly broad pattern — any argument beginning with -- (except --interactive) triggers CLI mode, which would cause false positives for unrelated flags like --help or framework-level options. Scoping the check to only the known installer params would be safer.
  • The hostIpip rename in the analytics payload is a server-side contract change. If the Growth API at growth.appwrite.io still expects hostIp, the IP data will be silently dropped with no visible error, since the HTTP call failure is swallowed in a bare catch (\Throwable) block.
  • No test plan was provided in the PR description, making it difficult to verify the intended behaviour across edge cases (no flags, only --interactive, --help, etc.).

Confidence Score: 2/5

  • Not safe to merge until the broad CLI-param detection is tightened and the Growth API key rename is confirmed coordinated.
  • Two meaningful issues lower confidence: (1) the open-ended -- prefix check in hasExplicitCliParams() will produce false positives for any unrelated double-dash flag, silently altering installer behaviour; (2) the hostIpip rename is an undocumented API contract change that will silently discard IP data if the receiving endpoint hasn't been updated. Neither issue is catastrophic, but both can cause subtle, hard-to-diagnose problems in production.
  • src/Appwrite/Platform/Tasks/Install.php — specifically the hasExplicitCliParams() method and the analytics payload key rename.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Tasks/Install.php Adds hasExplicitCliParams() to auto-detect CLI params and skip the web installer, and renames the hostIp analytics key to ip. The detection logic is overly broad (any -- arg bypasses the web installer), and the key rename may silently break the Growth API contract if not coordinated with the backend.

Reviews (1): Last reviewed commit: "(feat): auto-detect cli params to force ..." | Re-trigger Greptile

Comment on lines +1271 to +1278
{
$argv = $_SERVER['argv'] ?? [];
foreach ($argv as $arg) {
if (\str_starts_with($arg, '--') && !\str_starts_with($arg, '--interactive')) {
return true;
}
}
return false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Overly broad -- detection causes false positives

The function returns true for any argument beginning with -- (other than --interactive). This means flags like --help or --version — which a user might pass just to inspect the command — will silently bypass the web installer and drop the user into CLI mode. It will also capture framework-level double-dash options that have nothing to do with installer configuration.

A safer approach is to only match the known installer params (--http-port, --https-port, --organization, --image, --no-start, --database) rather than using an open-ended prefix check:

private function hasExplicitCliParams(): bool
{
    $installerParams = [
        '--http-port', '--https-port', '--organization',
        '--image', '--no-start', '--database',
    ];
    $argv = $_SERVER['argv'] ?? [];
    foreach ($argv as $arg) {
        $argName = explode('=', $arg, 2)[0];
        if (in_array($argName, $installerParams, true)) {
            return true;
        }
    }
    return false;
}

This is both explicit about intent and immune to false positives from unrelated flags.

'domain' => $domain,
'database' => $database,
'hostIp' => $hostIp !== $domain ? $hostIp : null,
'ip' => $hostIp !== $domain ? $hostIp : null,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 hostIpip rename may silently break the Growth API contract

The analytics payload key was renamed from hostIp to ip, but this is a server-side contract with https://growth.appwrite.io/v1/analytics. If the receiving API still expects the field named hostIp, the IP value will silently be discarded on the server side with no error returned to the caller (the catch (\Throwable) block at line 784 swallows any response failures too).

Please confirm that the Growth API has already been (or will atomically be) updated to accept ip before this change is deployed.

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
src/Appwrite/Platform/Tasks/Install.php (1)

1270-1276: Consider using an exact match for --interactive exclusion.

The current check !\str_starts_with($arg, '--interactive') also excludes any argument starting with --interactive (e.g., a hypothetical --interactive-mode). For more precise matching, consider checking the exact flag or its value variants.

♻️ Suggested refinement
 private function hasExplicitCliParams(): bool
 {
     $argv = $_SERVER['argv'] ?? [];
     foreach ($argv as $arg) {
-        if (\str_starts_with($arg, '--') && !\str_starts_with($arg, '--interactive')) {
+        if (\str_starts_with($arg, '--') && $arg !== '--interactive' && !\str_starts_with($arg, '--interactive=')) {
             return true;
         }
     }
     return false;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Tasks/Install.php` around lines 1270 - 1276, The
hasExplicitCliParams method currently treats any argument beginning with
--interactive as the same as the exact flag, which incorrectly excludes flags
like --interactive-mode; update the check so it only ignores the exact flag and
legitimate value forms (e.g., '--interactive' or '--interactive=...') by
replacing the negative str_starts_with condition with a precise test: return
true for any --... argument except when $arg === '--interactive' or when it
begins with '--interactive='; reference hasExplicitCliParams and the $argv loop
to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/Appwrite/Platform/Tasks/Install.php`:
- Around line 1270-1276: The hasExplicitCliParams method currently treats any
argument beginning with --interactive as the same as the exact flag, which
incorrectly excludes flags like --interactive-mode; update the check so it only
ignores the exact flag and legitimate value forms (e.g., '--interactive' or
'--interactive=...') by replacing the negative str_starts_with condition with a
precise test: return true for any --... argument except when $arg ===
'--interactive' or when it begins with '--interactive='; reference
hasExplicitCliParams and the $argv loop to locate the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bbca9f83-419e-4e1d-82f2-7ba512b6ae31

📥 Commits

Reviewing files that changed from the base of the PR and between 7fcc640 and dc6b2ce.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Tasks/Install.php

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit dc6b2ce - 3 flaky tests
Test Retries Total Time Details
UsageTest::testVectorsDBStats 1 10.04s Logs
TablesDBConsoleClientTest::testPatchAttribute 1 66ms Logs
TablesDBConsoleClientTest::testTimeout 1 122.80s Logs

@github-actions
Copy link
Copy Markdown

✨ Benchmark results

  • Requests per second: 1,686
  • Requests with 200 status code: 303,458
  • P99 latency: 0.102506931

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,686 1,217
200 303,458 219,149
P99 0.102506931 0.18950423

@blacksmith-sh
Copy link
Copy Markdown

blacksmith-sh bot commented Mar 25, 2026

Found 1 test error on Blacksmith runners:

Error

Test View Logs
› Tests\E2E\Services\Databases\LegacyCustomServerTest/testTimeout View Logs

Fix in Cursor

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.

1 participant