feat(cli): add --config option for custom config file path#307
feat(cli): add --config option for custom config file path#307hubertdeng123 merged 1 commit intomainfrom
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧Release
Other
🤖 This preview updates automatically when you update the PR. |
dad1de8 to
35acf14
Compare
Allow users to specify a custom devservices config file via `devservices --config /path/to/config.yml <command>`, bypassing the default config discovery logic.
35acf14 to
8f89003
Compare
| raise ServiceNotFoundError(error_message) | ||
| if config_path is not None: | ||
| config_path = os.path.abspath(config_path) | ||
| repo_path = os.getcwd() |
There was a problem hiding this comment.
Bug: When using the --config flag, repo_path is incorrectly set to the current working directory instead of being derived from the provided config_path, causing subsequent commands to fail.
Severity: CRITICAL
Suggested Fix
Modify the logic to derive repo_path from the absolute path of the config_path provided. The path should be the grandparent directory if the config is inside a devservices/ directory, or the parent directory otherwise, as stated in the pull request's description.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: devservices/utils/services.py#L63
Potential issue: When a user specifies a custom configuration file using the `--config`
flag, the `repo_path` variable is incorrectly set to the current working directory
(`os.getcwd()`) instead of being derived from the provided `config_path`. Downstream
commands such as `up`, `down`, and `status` rely on `repo_path` to reconstruct the path
to the configuration file. If the command is run from a directory different from the one
containing the config file, this leads to an incorrect path, causing the command to fail
with an error like `ConfigNotFoundError`. This breaks the feature's primary use case of
pointing to configurations in non-standard locations.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| raise ServiceNotFoundError(error_message) | ||
| if config_path is not None: | ||
| config_path = os.path.abspath(config_path) | ||
| repo_path = os.getcwd() |
There was a problem hiding this comment.
repo_path uses cwd instead of config file location
High Severity
When config_path is provided, repo_path is set to os.getcwd() instead of being derived from the config file's location. The PR description explicitly states repo_path should be the grandparent directory if the config is inside a devservices/ directory, or the parent directory otherwise. All downstream commands reconstruct the config file path as os.path.join(service.repo_path, DEVSERVICES_DIR_NAME, CONFIG_FILE_NAME), so docker-compose, supervisor, and log operations will reference the wrong config file — not the one specified by --config.


Add a global
-c/--configCLI option to specify a custom devservicesconfig file path, bypassing the default config discovery logic (cwd-based
or coderoot service name lookup).
This is useful for testing config changes without modifying the repo's
actual config file, or for pointing at configs in non-standard locations.
When
--configis provided:repo_pathis derived from the config file's location (grandparentif inside a
devservices/directory, otherwise parent directory)