Skip to content

Commit 0db1205

Browse files
fix(cli): fix project resolution in env vars subcommands and services env response (#59)
* fix(cli): fix project resolution in env vars subcommands and services env response parsing Two bugs fixed: 1. `environments vars` subcommands (get, set, delete, import, export) used `cmd.parent!.parent!.opts().project` to read the `--project` flag, traversing one level too high in the command hierarchy. The `--project` flag is defined on the `vars` command, so the correct traversal is `cmd.parent!.opts().project`. The `list` subcommand already did this correctly. Before: `temps envs vars -p my-app delete KEY` → "Project undefined not found" After: `temps envs vars -p my-app delete KEY` → successfully deletes 2. `services env` command crashed with "envVars is not iterable" because the API endpoint returns `HashMap<String, String>` (a plain object) but the CLI expected `Array<EnvironmentVariableInfo>`. Added handling to convert the object response into the expected array format. Before: `temps services env --id 1 -p my-app` → "envVars is not iterable" After: `temps services env --id 1 -p my-app` → displays variables correctly * docs: add CLI env vars fixes to changelog [Unreleased]
1 parent 2ca89d2 commit 0db1205

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
- Bump `testcontainers` 0.27.1 → 0.27.2 / `astral-tokio-tar` 0.5.6 → 0.6.0 (insufficient PAX extension validation, dev-only)
3232

3333
### Fixed
34+
- **CLI: `environments vars` subcommands ignored `--project` flag**: `get`, `set`, `delete`, `import`, `export` used `cmd.parent!.parent!.opts().project` (traversing to `environments` command level where `--project` isn't defined) instead of `cmd.parent!.opts().project` (the `vars` command where it is). This caused "Project undefined not found" errors. The `list` subcommand was not affected.
35+
- **CLI: `services env` crashed with "envVars is not iterable"**: the API endpoint `GET /external-services/{id}/projects/{project_id}/environment` returns `HashMap<String, String>` but the CLI expected `Array<EnvironmentVariableInfo>`. Added handling to convert the object response into the expected array format.
3436
- Email event timeline returned 404: UI fetched from `/emails/{id}/events` (unregistered plugin route) instead of `/emails/{id}/tracking/events`; also fixed event type mismatches (`open`/`click` vs `opened`/`clicked`) and added client-side pagination for flat array response
3537
- Gmail image proxy misidentified as "Firefox" in email tracking events; now shows "Gmail (Google Proxy)"
3638
- Email detail back button navigated to default Providers tab instead of Sent Emails tab

apps/temps-cli/src/commands/environments/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export function registerEnvironmentsCommands(program: Command): void {
8181
.description('Get a specific environment variable')
8282
.option('-e, --environment <name>', 'Specify environment (if variable exists in multiple)')
8383
.action(async (key, options, cmd) => {
84-
const projectSlug = cmd.parent!.parent!.opts().project
84+
const projectSlug = cmd.parent!.opts().project
8585
return getEnvVar(projectSlug, key, options)
8686
})
8787

@@ -92,7 +92,7 @@ export function registerEnvironmentsCommands(program: Command): void {
9292
.option('--no-preview', 'Exclude from preview environments')
9393
.option('--update', 'Update existing variable instead of creating new')
9494
.action(async (key, value, options, cmd) => {
95-
const projectSlug = cmd.parent!.parent!.opts().project
95+
const projectSlug = cmd.parent!.opts().project
9696
return setEnvVar(projectSlug, key, value, options)
9797
})
9898

@@ -104,7 +104,7 @@ export function registerEnvironmentsCommands(program: Command): void {
104104
.option('-e, --environment <name>', 'Delete only from specific environment')
105105
.option('-f, --force', 'Skip confirmation')
106106
.action(async (key, options, cmd) => {
107-
const projectSlug = cmd.parent!.parent!.opts().project
107+
const projectSlug = cmd.parent!.opts().project
108108
return deleteEnvVar(projectSlug, key, options)
109109
})
110110

@@ -114,7 +114,7 @@ export function registerEnvironmentsCommands(program: Command): void {
114114
.option('-e, --environments <names>', 'Comma-separated environment names')
115115
.option('--overwrite', 'Overwrite existing variables')
116116
.action(async (file, options, cmd) => {
117-
const projectSlug = cmd.parent!.parent!.opts().project
117+
const projectSlug = cmd.parent!.opts().project
118118
return importEnvVars(projectSlug, file, options)
119119
})
120120

@@ -124,7 +124,7 @@ export function registerEnvironmentsCommands(program: Command): void {
124124
.option('-e, --environment <name>', 'Export from specific environment')
125125
.option('-o, --output <file>', 'Write to file instead of stdout')
126126
.action(async (options, cmd) => {
127-
const projectSlug = cmd.parent!.parent!.opts().project
127+
const projectSlug = cmd.parent!.opts().project
128128
return exportEnvVars(projectSlug, options)
129129
})
130130

apps/temps-cli/src/commands/services/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,15 @@ async function envAction(options: EnvOptions): Promise<void> {
10731073
if (error) {
10741074
throw new Error(getErrorMessage(error))
10751075
}
1076+
// API returns HashMap<String, String> but OpenAPI spec says Vec<EnvironmentVariableInfo>
1077+
// Handle both formats for compatibility
1078+
if (data && !Array.isArray(data)) {
1079+
return Object.entries(data as Record<string, string>).map(([name, value]) => ({
1080+
name,
1081+
value: String(value),
1082+
sensitive: /password|secret|token|key/i.test(name),
1083+
}))
1084+
}
10761085
return data ?? []
10771086
})
10781087

0 commit comments

Comments
 (0)