Repository navigation
chore: absorb dsn into packages/dsn - #13894
Conversation
feat: initial commit
feat: Add linter workflow
Previously, DSN would not be able to parse special characters like "@" or "/". This adds support by requiring the input to be url encoded and then DSN would decode it after parsing.
Update DSN to support special chars for user and password
Tests for PHP 8.2
Feat throw on no scheme or host
parse_url() rejects the mistakes people actually make in a DSN (an empty host after the userinfo, a port out of range, a secret key with an unencoded "/"), and the refusal quoted the whole DSN back, user and password included. Anything that logs the message, or lets the exception escape to stderr, wrote the credentials out with it. Nothing of the input is kept: redacting only the userinfo would mean picking apart a string parse_url() has just refused, and the query can carry secrets of its own. The scheme and host refusals already quoted nothing; the regression test pins all three. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the message clean, the refusal's stack trace still printed the DSN argument, cut to zend.exception_string_param_max_len (15 bytes by default): the scheme, the user and the start of the password. Traces carry arguments unless zend.exception_ignore_args is on, and it is off by default and in the official PHP images, which ship no php.ini. #[\SensitiveParameter] prints the argument as Object(SensitiveParameterValue) instead. PHP before 8.2 ignores the attribute, so the trace test runs from 8.2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
SensitiveParameter only takes effect from PHP 8.2, and this package still supports 8.0 and 8.1, where the refusal's trace kept printing the DSN argument. A trace prints a parameter's current value rather than the one passed, so the constructor drops $dsn once parse_url() is done with it, and the trace test now runs on every supported version. The test no longer pins how PHP renders a redacted argument (NULL before 8.2, Object(SensitiveParameterValue) from 8.2): it asserts that neither the user nor the password is printed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix: keep credentials out of DSN parse failures
|
| ## Tests | ||
|
|
||
| ```bash | ||
| composer test |
There was a problem hiding this comment.
Standalone test command cannot run
After a fresh checkout of the standalone DSN package and composer install, the documented composer test command cannot find PHPUnit: the package runs phpunit but does not declare it as a dependency. The monorepo test runner supplies PHPUnit from the root toolchain, so the command works there but leaves standalone contributors without a working test path. Please document the monorepo command or provide a standalone test dependency.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/dsn/README.md
Line: 40
Comment:
**Standalone test command cannot run**
After a fresh checkout of the standalone DSN package and `composer install`, the documented `composer test` command cannot find PHPUnit: the package runs `phpunit` but does not declare it as a dependency. The monorepo test runner supplies PHPUnit from the root toolchain, so the command works there but leaves standalone contributors without a working test path. Please document the monorepo command or provide a standalone test dependency.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
# Conflicts: # composer.lock
# Conflicts: # composer.json # composer.lock
# Conflicts: # composer.lock # rfc/monorepo.md
# Conflicts: # composer.json # composer.lock
# Conflicts: # composer.lock # rfc/monorepo.md
# Conflicts: # composer.lock
# Conflicts: # composer.lock # rfc/monorepo.md
# Conflicts: # composer.lock
# Conflicts: # composer.lock # rfc/monorepo.md
Summary
This moves
utopia-php/dsnintopackages/dsn, so Appwrite loads it directly, and upgrades Appwrite from0.2.1to1.0.0in the process. It follows the playbook inrfc/monorepo.md(wave 1 of #13828) and comes in three commits:Add 'packages/dsn/' from commit '6d0e0aa9…': subtree import from the standalone repository with full history. The head is the1.0.0tag.chore(dsn): mirror plumbing:absorbwritesmirror.yml, removes the oldlinter.ymlandpull_request.ymlworkflows, adds the README banner, and strips Pint, PHPUnit and PHP_CodeSniffer fromrequire-devalong with thelint/formatscripts.refactor: load dsn from packages/:replaceentries, drops theutopia-php/dsn: 0.2.1require line, and removes the package from the lock. The lock diff is that one package plus the content hash.src/DSN/DSN.phpmoves up tosrc/.tests/DSN/DSNTest.phpmoves up totests/, and its namespace goes fromTests\Unit\DSNtoUtopia\DSN\Tests, with a matchingautoload-deventry.@dataProviderannotation becomes a#[DataProvider]attribute, since PHPUnit 12 ignores the annotation.phpunit.xmlis rewritten for PHPUnit 12.vimeo/psalmleavesrequire-dev(there was nopsalm.xml), and.gitignoregainscomposer.lockand.phpunit.cache.composer lint/format, which no longer exist, so it's now justcomposer test.phpstan.neonat level max oversrcandtests, plusrector.php. The standalone repository had no PHPStan config. Aphpstan-baseline.neonholds 4 findings: the untyped$paramsarray,parse_url()'s integer port stored in a?stringproperty, andgetParam()returning themixedparsed query value. The RFC's phase 8 burn-down list now includes them.There's nothing to hoist, since the package requires only PHP.
The 1.0.0 upgrade
The only change from
0.2.1is utopia-php/dsn#10: when a DSN fails to parse, the exception message is nowUnable to parse DSN: malformedinstead of echoing the DSN, and the constructor argument is#[\SensitiveParameter]. The exception type (\InvalidArgumentException) and the API are unchanged. The 26 Appwrite files that useUtopia\DSNonly catch the type, and nothing inapp/,src/ortests/asserts on the message, so Appwrite needs no changes. The benefit is that a malformed database or queue DSN no longer leaks its credentials into logs.Cross-repo
utopia-php/migration(still vendored, lock2.0.7) requiresutopia-php/dsn: 0.2.*. Inside Appwrite,replacesatisfies that, and Packagist consumers of migration keep installing dsn 0.2.x. The constraint moves to^1.0when migration is absorbed (wave 5 of #13828).Validation
bin/monorepo validate: all packages validbin/monorepo check dsn: Rector, Pint, and PHPStan level max (with baseline) passbin/monorepo test dsn: 7 tests / 112 assertionsvendor/bin/phpunit --testsuite packages --filter 'Utopia\\DSN': 7 tests / 112 assertions under the root autoloaderUtopia\DSN\DSNresolves topackages/dsn/src/DSN.php, and nothing is left undervendor/utopia-php/dsnUtopia\DSN(on the host): no errorsvendor/bin/phpunit tests/unit/Auth/Validator/PasswordPwned tests/unit/Platform/Modules/Databases/PoolTest.php: 37 tests passcomposer validate --no-check-publish: validbin/monorepo split dsn --dry-run:6538569d, which fast-forwards from the mirror head6d0e0aa9(2 commits)git diff --checkMerge and follow-up
Warning
Merge with a merge commit, not a squash. A squash drops the
git-subtree-*annotation and orphans the package from its mirror.utopia-php/dsnhad amainruleset (id23926928), created today, that required one approving review and let only org admins and repository admins bypass it, so the split app would have been rejected.absorbnormalised it in place to the canonical config: default branch, deletion and non-fast-forward blocked, PR required with 0 approvals, and the split app (4016286) as the only always-bypass actor.After merge: confirm
Splitpushes toutopia-php/dsn. Then triage the mirror's one open item, issue utopia-php/dsn#7 ("Add code formatter and CI/CD linter", a 2024 codeday task). It asks for Pint,lint/formatscripts and a lint workflow. The root toolchain now provides all three (bin/monorepo check dsn), so it can be closed with a pointer here. The repository has no open PRs.🤖 Generated with Claude Code