Accept 200 and 201 when re-associating a changed condition node - #241
Accept 200 and 201 when re-associating a changed condition node#241blaipr wants to merge 2 commits into
Conversation
When an existing condition edge's parameters change, condition_nodes disassociates the edge and posts it again. That second post set changed only on a 204 and let a 200 or a 201 through without setting it, while the new-association path a few lines below accepts all three. The disassociate that runs first returns 204 and already sets the flag, so no run reported the wrong result. This only makes the two paths agree on what a successful association looks like.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Pull request overview
Aligns the workflow_job_template_node module’s condition_nodes re-association behavior with the existing “new association” path so successful association responses (200/201/204) are handled consistently and reflected in Ansible’s changed result.
Changes:
- Treat 200/201/204 as successful status codes when re-associating a condition edge whose parameters changed, and mark
changed=Truein those cases. - Add a changelog fragment documenting the alignment and rationale.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| plugins/modules/workflow_job_template_node.py | Updates the condition_nodes re-association status-code handling to match the new-association logic. |
| changelogs/fragments/fix-condition-node-reassociate-changed.yml | Documents the behavior change under minor_changes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The disassociate that runs before re-associating a changed condition edge had its response read only to set changed on a 204. Anything else fell straight through to the re-associate, so a 4xx or a 5xx was hidden and the edge was left in whatever state the controller had put it in. It now fails with the returned detail, which is what the disassociate of a removed edge has always done. Both disassociates read the same way now. Reported by Copilot on ctrliq#241.
|
Copilot is right on this one, so it is fixed in 77970a7. The re-association path read the disassociate response only to set if response['status_code'] == 204:
module.json_output['changed'] = True
+ else:
+ module.fail_json(
+ msg=f"Failed to disassociate condition node {response['json'].get('detail', response['json'])}"
+ )
response = module.post_endpoint(condition_endpoint, **{'data': dc})That is the same shape as the "Disassociate removed condition nodes" block above it, which has always failed fast, so the two disassociates now read identically and the two associates already did after the first commit here. The changelog fragment gains a
|
Summary
When an existing condition edge's parameters change,
condition_nodesdisassociates the edge and posts it again. That second post setchangedonly on a 204, and let a 200 or a 201 through without setting it:The new-association path a few lines below already accepts all three, so the two halves of the same operation disagreed on what a successful association looks like.
No run reports the wrong result today: the disassociate that runs first returns 204 and sets the flag before the re-association is attempted, so the missing case is unreachable while the API keeps returning 204 for these relation endpoints. This makes the two paths agree rather than fixing an observable failure, which is why the changelog fragment lands under
minor_changesrather thanbugfixes.Type of Change
Component
workflow_job_template_node, thecondition_nodesre-association path.Checklist
ansible-test sanity, ansible-core 2.21.1 on Python 3.12)ruff,yamllint,ansible-lint)