Skip to content

fix(cli): accept /api paths, positional env pairs, and hint at login on 401 - #1130

Merged
Hydralerne merged 1 commit into
oblien:mainfrom
Metehan-Bicer:fix/cli-api-path-and-env-set
Oct 11, 2026
Merged

Hydralerne merged 1 commit into
oblien:mainfrom
Metehan-Bicer:fix/cli-api-path-and-env-set

Conversation

@Metehan-Bicer

Copy link
Copy Markdown
Contributor

Summary

Fixes three of the CLI problems in #1023: openship api no longer doubles the /api prefix, project env set accepts KEY=VALUE pairs as arguments, and project commands say to run openship login when the API answers 401.

Motivation

  • api.ts always puts the path under /api, so openship api /api/projects/<id> (the path as the API routes name it) requested /api/api/projects/<id> and got 404 Not Found.
  • project env set <id> FOO=bar failed with too many arguments for 'set'. Expected 1 argument but got 2., because the command only took pairs through --set.
  • A project command without a valid token printed a bare Unauthorized. The server and service commands already say "Run openship login first."

Related issue

Fixes #1023. Point 4 (--local-path) is already explained in the option's help, so it isn't changed here.

Changes

  • apps/cli commands/api.ts: a leading /api segment is stripped before the client adds its own (/api and /api/... only; /apis is left alone). /projects/x, projects/x and /api/projects/x now all request /api/projects/x.
  • apps/cli commands/project.ts:
    • env set takes optional [pairs...], merged with --set and checked by the same parsePairs; --set works as before. The --secret help and the "Nothing to do" message mention the positional pairs.
    • On a 401, the project command's error path adds "Run openship login first."; other statuses print as before. Commands in project-management.ts and project-data.ts report through the shared fail() and are unchanged.
  • apps/web content/docs/cli/reference/project/index.mdx: the generated reference for env set, matching the new --help (checked against the repo's generator).
  • Tests: apps/cli/test/e2e/api.test.ts and apps/cli/test/e2e/project.test.ts.

Verification

# apps/cli
$ bun x vitest run test/e2e/api.test.ts test/e2e/project.test.ts
 Tests  23 passed (23)
# with the two source files reverted, four new tests fail:
#   api > does not double the /api prefix when the path already has it   (got http://api.test/api/api/projects/x)
#   project env set > accepts positional KEY=VALUE pairs the same as --set, and both together
#   project env set > rejects a malformed positional pair before sending a write
#   project auth errors > points at openship login when the API answers 401   (got "  Unauthorized\n")

$ bun x vitest run
 Tests  718 passed (718)

$ bun run --cwd apps/cli lint   # clean

Against a local API (apps/api on port 4400, a project created with project create --local-path …):

$ openship api /api/projects/<id>
before: 404 Not Found
after:  { "data": { "id": "<id>", … } }

$ openship project env set <id> FOO=bar --set BAZ=qux
before: error: too many arguments for 'set'. Expected 1 argument but got 2.
after:  Updated env (production): 2 upserted, 0 deleted   (env get lists FOO and BAZ)

$ openship project list   # API with OPENSHIP_AUTH_MODE=local, no token
before: Unauthorized
after:  Unauthorized
        Run `openship login` first.

project.ts, project.test.ts and the docs page already have Prettier drift upstream. The two changed lines in project.ts keep that file's one-line style (the upserts line was already this long), so I didn't run bun format over them.

Checklist

…on 401

`openship api /api/projects/<id>` requested /api/api/... because the
client always prefixes /api; a leading /api segment is now stripped.
`project env set <id> KEY=VALUE` failed with "too many arguments"; the
pairs are now accepted next to --set. A 401 from a project command now
adds "Run `openship login` first.", as server and service commands do.

Fixes oblien#1023
@Hydralerne
Hydralerne merged commit eddcb20 into oblien:main Oct 11, 2026
@Hydralerne

Copy link
Copy Markdown
Member

Great, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CLI misleading errors: bare Unauthorized, env set syntax, undiscoverable api paths, --local-path false "Directory not found"

2 participants