Repository navigation
Validate log --service, --app and --worker names against the deployment - #244
Conversation
Unknown --service/--app names were sent to the logs API unchecked and just returned "No logs found", and --worker forced SSH. Names are now checked against the current deployment, and workers are filtered via the API. Requested-by: Patrick Dawkins Dispatch-Run: 01M502FSZ9H4K1AGZWJ45ZYGCA Dispatch-Attempt: 1
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning · 🔵 1 minor point
🔍 Full review · 3 files reviewed
Verification
buildFilters()is called only once, fromreadFromApi()before the time window is parsed, so the worker prompt and the verboseSelected workerline come once per command, not once per page or per tail poll.selectWorkerName()keeps the old worker branch unchanged: the case-insensitive conflict check, direct lookup, suffix match, the non-interactive ambiguity error and the prompt.selectRemoteContainer()still wraps the result withgetWorker().Selection::getAppName()already merges the--appoption, the app ID from the project URL and<PREFIX>APPLICATION_NAME, soresolveServices()validates the app from all three sources.Api::getCurrentDeploymentthrowsEnvironmentStateExceptionfor inactive environments, sologon an inactive environment falls back to the no-validation path and does not fail.
TestEnvironmentLogAPI in integration-tests/environment_log_test.go adds a deployment fixture and covers worker resolution, invalid service/app/worker errors and that no query is sent after an error. Nothing tests the path where there is no current deployment. The refactored SSH worker path is covered by the existing TestSSHAppSelection cases, which the author could not run locally.
Review details
- Commit: 902c4e8
- Model: claude-opus-5-5
Review 1 of 10 for this pull request · View the full run
Logs of removed or renamed services are retained, so a name that is not in the current deployment now prints a warning (with the log type hint) and is still queried, instead of failing. Qualified worker names (<app>--<worker>, or a short name with --app) are passed through in the same way, via the new Selector::qualifyWorkerName(). Only a bare short worker name needs the deployment to be resolved. The current deployment is no longer fetched when there are no service, app or worker filters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
📋 PR Summary With the Changes
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the
autolog protocol,lognow checks--service,--appand--workeragainst the environment's current deployment. An unknown name prints a warning listing the valid names, and is still queried, as logs of removed or renamed services are retained. If the name is a log type (e.g.--service access), the warning suggests passing it as an argument instead.--workerno longer forces SSH: it filters the logs API by the worker's qualified<app>--<worker>name. A bare short name is resolved against the deployment with the same rules asssh --worker(now inSelector::selectWorkerName()), so an ambiguous or missing short name is an error. A qualified name, or a short name with--app, is passed through (Selector::qualifyWorkerName()).The deployment is only fetched when a service, app or worker filter is set. If there is no current deployment, names are not validated, and a short
--workername without an app is an error.Not checked: that the logs API names worker logs
<app>--<worker>(as the metrics commands do), and thatrouteris a valid logs service name. Before merging, runlog --format jsonon an environment with a worker and check theservicefield.Changes:
legacy/src/Selector/Selector.php: the--workerbranch ofselectRemoteContainer()is split intoqualifyWorkerName()andselectWorkerName(), with the same messages and prompt.legacy/src/Command/Environment/EnvironmentLogCommand.php: newresolveServices();--workerno longer triggers SSH (the help text is updated).integration-tests/environment_log_test.go: adds a deployment toTestEnvironmentLogAPI, and covers worker selection, warnings for unknown names (with and without the log type hint), and short worker name errors.Created by Upsun Dispatch™, review comments addressed by Claude Code.
🤖 Generated with Claude Code