Skip to content

fix(projects): auto-generate identifier on project create - #8

Open
OmarAdel10 wants to merge 1 commit into
cpatrickalves:mainfrom
OmarAdel10:fix/project-create-auto-identifier
Open

fix(projects): auto-generate identifier on project create#8
OmarAdel10 wants to merge 1 commit into
cpatrickalves:mainfrom
OmarAdel10:fix/project-create-auto-identifier

Conversation

@OmarAdel10

Copy link
Copy Markdown

Summary

Fixes project new <name> failing when no -i flag is given. The Plane API requires a project identifier, but the CLI previously sent CreateProject(name=...) with no identifier, causing the create to be rejected. The identifier is now auto-generated from the project name (first 5 alphanumeric characters, uppercased) when not explicitly provided.

Problem

planecli project new "My Project"

sent CreateProject with a missing identifier field. The Plane API rejects project creation without an identifier, so the command failed unless the user remembered to pass -i FE etc. The --help text already documented "Auto-generated if not specified" — this PR makes the CLI honor that contract.

Change

  • src/planecli/commands/projects.py
    • New _default_identifier(name) helper: derives an identifier from the project name (alphanumeric characters only, max 5, uppercased).
    • create now always sends an identifier: the explicit -i value wins; otherwise the derived default is used. Explicit identifiers are still uppercased as before.
  • tests/test_projects.py (new)
    • Covers derivation from a normal name, punctuation stripping, short names, and uppercasing.

Behavior

Before After
project new "My Backend API" → API error (missing identifier) project new "My Backend API" → created with identifier MYBAC
project new "API" -i fe → created with FE unchanged (FE)

No breaking changes. No output-format changes.

Testing

make check (ruff format + ruff lint + pytest) — all green:

145 passed in 1.91s

Includes the 4 new tests/test_projects.py tests.

Notes

  • Single-file source change; submitted via fork (OmarAdel10/plane-cli) since write access to this repo is not available.
  • Branch: fix/project-create-auto-identifier

- `project new <name>` without `-i` previously sent CreateProject with no
  identifier, which the Plane API rejects.
- Add _default_identifier helper: derives identifier from the project name
  (first 5 alphanumeric chars, uppercased).
- Explicit -i flag still takes precedence; create now always sends an
  identifier.
- Add tests/test_projects.py covering derivation, punctuation stripping,
  short names, and uppercasing.
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.

1 participant