Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the 📝 WalkthroughWalkthroughThis pull request adds detection and reporting of environment variables found in .env files, using Swoole coroutines (WaitGroup) to parallelize fetching and parsing in two code paths of app/controllers/api/vcs.php (framework/runtime detection and repository processing). It introduces a new Detection model hierarchy: a Detection abstract model with a variables rule, a DetectionVariable model, and updates Response to register the new model and constant. DetectionFramework and DetectionRuntime now extend Detection. ProviderRepository model gains a variables field. A DNS test value was also changed in tests/unit/Network/Validators/DNSTest.php. Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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 |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
app/controllers/api/vcs.php (1)
1183-1195: See earlier comment on Lines 976-988 about decoding the GitHub content before parsing; the same fix is required here.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (4)
app/controllers/api/vcs.php(3 hunks)src/Appwrite/Utopia/Response/Model/DetectionFramework.php(1 hunks)src/Appwrite/Utopia/Response/Model/DetectionRuntime.php(1 hunks)src/Appwrite/Utopia/Response/Model/ProviderRepository.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/Appwrite/Utopia/Response/Model/ProviderRepository.php (1)
src/Appwrite/Utopia/Response/Model.php (1)
addRule(90-102)
src/Appwrite/Utopia/Response/Model/DetectionFramework.php (1)
src/Appwrite/Utopia/Response/Model.php (1)
addRule(90-102)
src/Appwrite/Utopia/Response/Model/DetectionRuntime.php (1)
src/Appwrite/Utopia/Response/Model.php (1)
addRule(90-102)
⏰ 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). (3)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
✨ Benchmark results
⚡ Benchmark Comparison
|
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
app/controllers/api/vcs.php (1)
17-17: Decode GitHub.envfile content before parsing (and treat it as text, not base64)In both
.env-scanning blocks you read the GitHub Contents APIcontentfield and split it directly:$contentResponse = $github->getRepositoryContent(...); $envFile = $contentResponse['content'] ?? ''; $envLines = \explode("\n", $envFile);The GitHub Contents API returns
contentbase64‑encoded, so this code parses base64 blobs instead of the actual.envtext. That makes all suggested variable names effectively garbage and breaks the feature.This is the same issue that was already raised in a previous review comment for this file; it still needs to be fixed. A robust pattern for both blocks would be:
- $envFile = $contentResponse['content'] ?? ''; + $envFileEncoded = $contentResponse['content'] ?? ''; + if (empty($envFileEncoded)) { + return; + } + + $envFile = \base64_decode($envFileEncoded, true); + if ($envFile === false) { + // Skip invalid content instead of trying to parse it + return; + }Then continue with
explode("\n", $envFile)on the decoded string. Please apply this in both the detection endpoint block and the repositories listing block.Also applies to: 968-1005, 1182-1217
🧹 Nitpick comments (2)
src/Appwrite/Utopia/Response/Model/Detection.php (1)
8-21: Sharedvariablesrule looks correctThe shared
variablesrule (array ofMODEL_DETECTION_VARIABLE) is wired correctly for Detection-based models, and the subclasses’parent::__construct()calls will ensure it’s always present. Note that withrequired => falsethedefaultvalue isn’t used byResponse::output(), but that’s a harmless no-op.app/controllers/api/vcs.php (1)
968-1005: Promote.envvariables to properDetectionVariabledocuments and de-duplicate parsing logicTwo smaller structural points:
Use
Documentfor variables to leverage model validationThe
Detectionmodels definevariablesastype => MODEL_DETECTION_VARIABLE, array => true, but here you push plain arrays. If you instead wrap each variable as aDocumentbefore callingdynamic()/output(), you’ll get consistent filtering and defaults from theDetectionVariablemodel:
$variables[] = ['name' => $key,'value' => $value,];
$variables[] = new Document(['name' => $key,'value' => $value,]);Same idea for `$repo['variables']`.
Extract shared
.envparsing into a helperThe two env blocks are almost identical. A small private helper (or even a closure above) that takes
$github, repo coordinates, and returns the variables array would reduce duplication and keep behavior consistent if you tweak parsing later.These are not blockers but would improve maintainability and data consistency.
Also applies to: 1182-1217
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
app/controllers/api/vcs.php(3 hunks)src/Appwrite/Utopia/Response.php(3 hunks)src/Appwrite/Utopia/Response/Model/Detection.php(1 hunks)src/Appwrite/Utopia/Response/Model/DetectionFramework.php(1 hunks)src/Appwrite/Utopia/Response/Model/DetectionRuntime.php(1 hunks)src/Appwrite/Utopia/Response/Model/DetectionVariable.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Appwrite/Utopia/Response/Model/DetectionRuntime.php
🧰 Additional context used
🧬 Code graph analysis (4)
src/Appwrite/Utopia/Response/Model/DetectionVariable.php (3)
src/Appwrite/Utopia/Response.php (2)
Response(159-983)__construct(428-632)src/Appwrite/Utopia/Response/Model.php (2)
Model(7-192)addRule(90-102)src/Appwrite/Utopia/Response/Model/Detection.php (1)
__construct(10-21)
src/Appwrite/Utopia/Response/Model/Detection.php (5)
src/Appwrite/Utopia/Response.php (2)
Response(159-983)__construct(428-632)src/Appwrite/Utopia/Response/Model.php (2)
Model(7-192)addRule(90-102)src/Appwrite/Utopia/Response/Model/DetectionFramework.php (1)
__construct(9-38)src/Appwrite/Utopia/Response/Model/DetectionRuntime.php (1)
__construct(9-32)src/Appwrite/Utopia/Response/Model/DetectionVariable.php (1)
__construct(10-25)
src/Appwrite/Utopia/Response/Model/DetectionFramework.php (2)
src/Appwrite/Utopia/Response/Model/Detection.php (2)
Detection(8-22)__construct(10-21)src/Appwrite/Utopia/Response/Model/DetectionRuntime.php (1)
__construct(9-32)
src/Appwrite/Utopia/Response.php (2)
src/Appwrite/Utopia/Response/Model.php (1)
Model(7-192)src/Appwrite/Utopia/Response/Model/DetectionVariable.php (1)
DetectionVariable(8-46)
🔇 Additional comments (2)
src/Appwrite/Utopia/Response/Model/DetectionFramework.php (1)
7-12: Detection now correctly shares the commonvariablesruleExtending
Detectionand callingparent::__construct()cleanly reuses the sharedvariablesrule without changing existing framework fields. Looks good.src/Appwrite/Utopia/Response.php (1)
62-63: DetectionVariable model is correctly registered in the response registryThe import,
MODEL_DETECTION_VARIABLEconstant, andsetModel(new DetectionVariable())hook cleanly into the existing model registry and follow the established pattern for other VCS-related models.Also applies to: 320-321, 568-569

What does this PR do?
Adds env variable names suggestions based on .env files in repository
Test Plan
Manual QA:
Related PRs and Issues
x
Checklist