Skip to content

Commit 149a355

Browse files
committed
[#74316] document JSON WP workflows
Add README examples for the new machine-readable Work Package flows: inspect with children, parent-aware create dry-runs, and schema-driven update dry-runs. https://community.openproject.org/projects/cli/work_packages/74316
1 parent 1dcf493 commit 149a355

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ op create workpackge --project 11 'Document new CLI tool'
150150

151151
# Same command with shorthands and directly open it in a browser to continue working on it.
152152
op create workpackge -p11 'Document new CLI tool' -o
153+
154+
# Validating the creation of a child work package without persisting it.
155+
# The parent determines the project automatically.
156+
op create workpackage --parent 74316 --type Implementation 'Build reusable skill' --dry-run --json
153157
```
154158

155159
#### Listing
@@ -191,6 +195,27 @@ op inspect workpackage 42
191195
op inspect workpackage 74316 --children --json
192196
```
193197

198+
#### JSON error codes
199+
200+
The `--json` variants of `inspect`, `create`, and `update` return a stable error envelope:
201+
202+
```json
203+
{"error": {"code": "<code>", "message": "<message>"}}
204+
```
205+
206+
| Code | Trigger | Mutation persisted? |
207+
|---|---|---|
208+
| `invalid_argument` | Missing positional arg, invalid id, local validation failure, malformed `--set`, or no update options under `--json`/`--dry-run` | No |
209+
| `conflicting_arguments` | Incompatible flag combinations, e.g. `--description` + `--set`, `--open` + `--json`, `--dry-run` without `--json` | No |
210+
| `api_error` | Underlying OpenProject API call failed while resolving, creating, updating, or dry-running a work package | No |
211+
| `post_apply_inspect_failed` | CREATE or PATCH succeeded but the follow-up inspect to build the JSON response failed — the mutation **has persisted**, only the response payload could not be assembled | **Yes** |
212+
| `ambiguous_field` | A `--set` label matched more than one schema field | No |
213+
| `duplicate_field` | A `--set` assignment names the same API field twice | No |
214+
| `unknown_field` | A `--set` label or API field is not present in the resolved schema | No |
215+
| `unsupported_field_type` | A `--set` field's schema type is not yet coercible | No |
216+
| `invalid_field_value` | A `--set` value fails type coercion (e.g. non-integer for an `Integer` field) | No |
217+
| `non_writable_field` | A `--set` field exists in the schema but is not writable | No |
218+
194219
## Creating a release
195220

196221
Releases are triggered by pushing a git tag. The tag name becomes the version string embedded in the binaries.

0 commit comments

Comments
 (0)