Skip to content

feat: support workflow version in run requests#150

Closed
Kaiser-Wu wants to merge 1 commit intocoze-dev:mainfrom
Kaiser-Wu:feature/support-workflow-version
Closed

feat: support workflow version in run requests#150
Kaiser-Wu wants to merge 1 commit intocoze-dev:mainfrom
Kaiser-Wu:feature/support-workflow-version

Conversation

@Kaiser-Wu
Copy link

What changed

  • add workflowVersion to RunWorkflowReq
  • serialize it as workflow_version
  • add a test to verify the request JSON includes workflow_version

Why

The workflow run API supports workflow_version, but the Java SDK request model did not expose it, so callers could not specify a workflow version.

Validation

  • env JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home PATH=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home/bin:$PATH mvn -Dmaven.repo.local=/tmp/coze-java-m2 -pl api -Dtest=WorkFlowRunServiceTest test

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

A new workflowVersion field is added to the RunWorkflowReq class for resource-library workflows, mapped to JSON property workflow_version. Omitting this field implies latest version behavior. A corresponding serialization test validates the field's presence in JSON output.

Changes

Cohort / File(s) Summary
Request Model Update
api/src/main/java/com/coze/openapi/client/workflows/run/RunWorkflowReq.java
Added workflowVersion field with @JsonProperty("workflow_version") annotation to support workflow version specification for resource-library workflows.
Serialization Test
api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowRunServiceTest.java
Added imports for Jackson ObjectMapper and JsonNode; defined static ObjectMapper instance; added testRunWorkflowReqSerializesWorkflowVersion test validating correct serialization of workflowVersion, workflowID, and appID fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

feature

Suggested reviewers

  • hanzeINGH

Poem

🐰 A version field hops into place,
Workflows now choose their pace,
JSON maps it with care so fine,
Tests confirm the design align,
Latest versions in a race! 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: support workflow version in run requests' clearly and concisely summarizes the main change: adding workflow version support to the request model.
Description check ✅ Passed The description is directly related to the changeset, explaining what changed, why it was needed, and how it was validated with clear test examples.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowRunServiceTest.java (1)

175-177: Prefer key-presence assertions before asText() for clearer failures.

At Line 175–Line 177, json.get(...).asText() can NPE when a field is absent; asserting key existence first makes failures explicit and easier to diagnose.

Proposed test assertion refinement
-    assertEquals("1.2.3", json.get("workflow_version").asText());
-    assertEquals("test_workflow_id", json.get("workflow_id").asText());
-    assertEquals("test_app_id", json.get("app_id").asText());
+    assertTrue(json.hasNonNull("workflow_version"));
+    assertTrue(json.hasNonNull("workflow_id"));
+    assertTrue(json.hasNonNull("app_id"));
+    assertEquals("1.2.3", json.get("workflow_version").asText());
+    assertEquals("test_workflow_id", json.get("workflow_id").asText());
+    assertEquals("test_app_id", json.get("app_id").asText());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowRunServiceTest.java`
around lines 175 - 177, Add explicit key-presence checks on the JSON node before
calling asText(): before the assertions that use json.get(...).asText() (the
three lines referencing "workflow_version", "workflow_id", and "app_id" in
WorkFlowRunServiceTest where the variable json is used), add assertions such as
assertTrue(json.has("workflow_version")), assertTrue(json.has("workflow_id")),
and assertTrue(json.has("app_id")) so failures indicate a missing key rather
than causing an NPE when asText() is called.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowRunServiceTest.java`:
- Around line 175-177: Add explicit key-presence checks on the JSON node before
calling asText(): before the assertions that use json.get(...).asText() (the
three lines referencing "workflow_version", "workflow_id", and "app_id" in
WorkFlowRunServiceTest where the variable json is used), add assertions such as
assertTrue(json.has("workflow_version")), assertTrue(json.has("workflow_id")),
and assertTrue(json.has("app_id")) so failures indicate a missing key rather
than causing an NPE when asText() is called.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2b085868-7cdc-4bd6-881f-a5b7ded7e940

📥 Commits

Reviewing files that changed from the base of the PR and between a1dad15 and 3289e73.

📒 Files selected for processing (2)
  • api/src/main/java/com/coze/openapi/client/workflows/run/RunWorkflowReq.java
  • api/src/test/java/com/coze/openapi/service/service/workflow/WorkFlowRunServiceTest.java

@Kaiser-Wu
Copy link
Author

Superseded by a dedicated workflow fix PR.

@Kaiser-Wu Kaiser-Wu closed this Mar 27, 2026
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.

2 participants