Skip to content

Guard URI retry loops against missing .json attribute#57

Merged
Oddly merged 1 commit intomainfrom
fix/cluster-status-default-guard
Mar 4, 2026
Merged

Guard URI retry loops against missing .json attribute#57
Oddly merged 1 commit intomainfrom
fix/cluster-status-default-guard

Conversation

@Oddly
Copy link
Copy Markdown
Owner

@Oddly Oddly commented Mar 1, 2026

When the URI module returns an error response (connection refused, 401, 503, etc.), the registered variable has no .json attribute. The until condition then crashes with dict object has no attribute 'json' instead of retrying, which is the whole point of the retry loop.

This wraps all .json accesses in until conditions with | default({}) so the outer attribute lookup returns an empty dict on error responses. The existing | default('') or | default(false) guards on the inner key then do their job and the retry loop continues as expected.

Affected files:

  • elasticsearch-security.yml — 4 until conditions (API availability checks, cluster status checks)
  • elasticsearch-rolling-upgrade.yml — 5 until conditions (shard allocation acknowledged, cluster health)
  • main.yml — 1 until condition (cluster status without security)

Fixes #52

@Oddly Oddly force-pushed the fix/cluster-status-default-guard branch 7 times, most recently from 0890d01 to ce511d8 Compare March 4, 2026 15:09
When the ansible.builtin.uri module returns an error response (connection
refused, 401, 503, etc.), the registered variable has no .json attribute.
Accessing .json.status or .json.cluster_name directly in an until condition
then crashes the retry loop with "dict object has no attribute 'json'" instead
of retrying as intended.

Wrap all .json accesses in until conditions with | default({}) so the outer
attribute lookup returns an empty dict on error, allowing the existing
| default('') or | default(false) guards to handle the missing inner key
gracefully and let the retry loop continue.

Fixes #52
@Oddly Oddly force-pushed the fix/cluster-status-default-guard branch from ce511d8 to 7f20fd2 Compare March 4, 2026 19:06
@Oddly Oddly merged commit dece188 into main Mar 4, 2026
13 of 32 checks passed
@Oddly Oddly deleted the fix/cluster-status-default-guard branch March 4, 2026 19:11
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.

elasticsearch-security.yml: cluster status check crashes on error response

1 participant