fix(ci): accept map-form dependencies in iii.worker.yaml#43
Conversation
Translate `dependencies:` in iii.worker.yaml into the array-of-objects wire
shape the registry's /publish endpoint expects. Authors can write the
friendlier map form:
dependencies:
math-worker: "^0.1.0"
...or the explicit array form. Both normalize to the same payload.
Without this translation, a worker declaring deps via the map form (the
shape parsed by iii CLI's new worker_manifest_deps.rs) would POST a JSON
object where the registry expects a JSON array, failing with 422 at
publish time.
Rejects any other shape (string, number, etc.) up front so the error is
visible in the workflow log, not hidden inside a registry response.
📝 WalkthroughWalkthroughThe workflow step that publishes to the registry now normalizes the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.github/workflows/_publish-registry.yml (1)
90-99: Consider coercingversionvalues to strings.YAML parses unquoted version-like scalars as numbers, e.g.
math-worker: 1.0→float(1.0)andmath-worker: 1→int(1). Both the map and list paths forward these as-is, so they'll be JSON-encoded as numbers and likely rejected by the registry (or worse, stored in a surprising shape). The PR's example uses quoted"^0.1.0", which sidesteps this, but a missing quote is an easy author mistake with a confusing 422 as the only signal.Low-risk fix — cast
versiontostrin both normalization branches:♻️ Proposed refactor
raw_deps = meta.get("dependencies") or [] if isinstance(raw_deps, dict): - deps = [{"name": k, "version": v} for k, v in raw_deps.items()] + deps = [{"name": str(k), "version": str(v)} for k, v in raw_deps.items()] elif isinstance(raw_deps, list): - deps = raw_deps + deps = [ + {**d, "version": str(d["version"])} + if isinstance(d, dict) and "version" in d + else d + for d in raw_deps + ] else: print( f"::error::`dependencies` must be a map or list, got {type(raw_deps).__name__}" ) sys.exit(1)Also note:
meta.get("dependencies") or []intentionally collapses{},[], andNoneto[], which matches the PR's stated "null/absent → []" behavior — leaving as-is.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/_publish-registry.yml around lines 90 - 99, Normalize dependency versions to strings before building deps: when converting raw_deps from a dict (the dict comprehension that produces deps) coerce each v to str (e.g. {"name": k, "version": str(v)}), and when handling the list branch, ensure each list element's "version" field is converted to str (or wrap scalar list entries accordingly) so deps always contains string versions; operate on the existing raw_deps/deps normalization logic shown in the diff.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.github/workflows/_publish-registry.yml:
- Around line 90-99: Normalize dependency versions to strings before building
deps: when converting raw_deps from a dict (the dict comprehension that produces
deps) coerce each v to str (e.g. {"name": k, "version": str(v)}), and when
handling the list branch, ensure each list element's "version" field is
converted to str (or wrap scalar list entries accordingly) so deps always
contains string versions; operate on the existing raw_deps/deps normalization
logic shown in the diff.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c3acfb9b-097e-4dc8-b483-e1c286daea3f
📒 Files selected for processing (1)
.github/workflows/_publish-registry.yml
Summary
_publish-registry.ymlpreviously forwardedmeta.get("dependencies", [])verbatim, assuming the yaml was already in the array-of-objects shape the registry's/publishendpoint expects. The in-flight iii CLI (iii-hq/iii) plan parsesdependencies:as a map iniii.worker.yaml— the natural, npm/cargo-style shape for authors:Without this patch, any worker written in the map form publishes a JSON object where the registry expects a JSON array and fails with 422. This blocks the end-to-end "author declares deps in yaml" feature.
Change
Normalize before building the payload:
[{name, version}, ...].[].::error::pointing at the bad shape.Compatibility
No worker in this repo currently declares
dependenciesin itsiii.worker.yaml, so this patch changes nothing for the 20 existing publish paths. It unblocks the new ones.Test Plan
dependencies:block and publishes, the registry row should contain the translated array. Verify viaGET /w/<name>or directly inworkerVersion.dependencies.Paired with
iii-hq/registry#8— registry-side Zod hardening that rejects invalid dep names/ranges at/publish. The two PRs are independent but both need to land for the yaml → registry feature to work end-to-end.Summary by CodeRabbit