Repository navigation
fix(cli): reject incomplete and trailing JSON in config files - #2135
Merged
ChiragAgg5k merged 1 commit intoOct 23, 2026
Merged
Conversation
🟢 Tier S · Ready to merge
The CLI JSON parser now requires complete objects and rejects any non-whitespace input after a top-level JSON value, including included resource arrays. The Go CLI e2e harness exercises malformed and valid config rewrites and checks that rejected inputs remain unchanged.
📂 Walkthrough · 3
Reviewed |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A stray closing brace in
appwrite.config.jsonmakes the CLI read only the first object, then silently delete the remaining resource definitions on its next write. Require a complete object and the end of the input after every top-level JSON value. Included resource arrays receive the same validation. Valid trailing whitespace, key order, and large integers remain supported.Fixes #2130.
The CLI e2e harness now exercises malformed root configs and included arrays, checks nonzero exits and byte-for-byte preservation of every input file, and verifies that a valid config still rewrites successfully without losing resources or integer precision. The new regression fails against the original generated CLI and passes with this change.
Staging verification
Verified on 2026-10-23 using the existing CLI staging login (
https://cloud.staging.appwrite.io/v1) and a disposable Frankfurt project (https://fra.cloud.staging.appwrite.io/v1). Built the original and patched generated CLIs with Go 1.26.5.For example, ran
appwrite client --project-id sdk-json-fix-oct23with this malformed local config linked to the disposable staging project:{"projectId":"sdk-json-fix-oct23","endpoint":"https://fra.cloud.staging.appwrite.io/v1","custom":{"keep":9007199254740993}},"tables":[{"$id":"orders","databaseId":"main","name":"Orders","columns":[]}]}tables}includes.tablespointing to an array followed by another valueordersand integer9007199254740993These are local config rewrites performed with the staging session; the sample resource entries were not pushed. The disposable project
sdk-json-fix-oct23was deleted after verification, and a subsequent get returned project-not-found.The missing-brace behavior above reproduces with Go 1.26, as in the issue. Go 1.27 already rejects those incomplete-object examples due to a decoder error change; the stray-brace/trailing-input data loss still reproduces on both versions without this fix.
Validation
php example.php cliand inspected the generated parser.gofmtwithout post-generation formatting.go build,go vet ./..., andgo test ./...pass.vendor/bin/phpunit tests/e2e/CLIGo126Test.phppasses.composer refactor:check,composer lint-twig, and scoped PHPCS pass.vendor/bin/phpstan analyse --memory-limit=2G tests/e2e/CLIGo126Test.phppasses (default level 0).Related: appwrite-labs/cloud#6667