Skip to content

Commit 9ab5d46

Browse files
yeldarbyclaude
andcommitted
fix(cli): address Codex review — api key passthrough, fork parsing, version ID
1. annotation job create: pass resolved API key to Roboflow() instead of relying on global config. Fixes auth failure in CI/non-interactive contexts when --api-key is provided. 2. workflow fork: extract URL from nested {"workflow": {"url": "..."}} response instead of assigning the whole dict to new_url. 3. version create: use return value from generate_version() directly instead of inferring via max(versions), which is race-prone if another version is created concurrently. 405 tests pass, all linting clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e158cc8 commit 9ab5d46

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

roboflow/cli/handlers/annotation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _job_create(args: argparse.Namespace) -> None:
237237

238238
with suppress_sdk_output(args):
239239
try:
240-
rf = roboflow.Roboflow()
240+
rf = roboflow.Roboflow(api_key=_api_key)
241241
workspace = rf.workspace(workspace_url)
242242
project = workspace.project(project_slug)
243243
except Exception as exc:

roboflow/cli/handlers/version.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,13 @@ def _create(args: argparse.Namespace) -> None:
299299
try:
300300
rf = roboflow.Roboflow(api_key)
301301
project = rf.workspace(workspace_url).project(project_slug)
302-
project.generate_version(settings)
302+
version_id = project.generate_version(settings)
303303
except Exception as exc:
304304
output_error(args, str(exc))
305305
return
306306

307-
# After generation, the latest version is the newly created one
308-
with suppress_sdk_output():
309-
try:
310-
versions = project.versions()
311-
version_num = max(int(v.version.split("/")[-1]) for v in versions) if versions else 1
312-
except Exception:
313-
version_num = 1
307+
# generate_version returns the version number/ID directly
308+
version_num = version_id if version_id else "unknown"
314309

315310
data = {"status": "created", "project": project_slug, "version": version_num}
316311
output(args, data, text=f"Created version {version_num} for project {project_slug}")

roboflow/cli/handlers/workflow.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,14 @@ def _fork_workflow(args: argparse.Namespace) -> None:
316316
output_error(args, str(exc))
317317
return
318318

319-
new_url = data.get("workflow", data.get("url", data.get("workflow_url", ""))) if isinstance(data, dict) else ""
319+
# Extract the forked workflow URL from potentially nested response
320+
new_url = ""
321+
if isinstance(data, dict):
322+
wf = data.get("workflow", data)
323+
if isinstance(wf, dict):
324+
new_url = str(wf.get("url", wf.get("workflow_url", "")))
325+
else:
326+
new_url = str(wf) if wf else ""
320327
result = {"status": "forked", "source": args.workflow_url, "new_url": new_url}
321328
text = f"Forked workflow: {args.workflow_url} -> {new_url}"
322329
output(args, result, text=text)

0 commit comments

Comments
 (0)