Fix _is_service_healthy nil-pointer crash for containers without a healthcheck - #51
Merged
Merged
Conversation
Use a safe Go template that checks for Health before accessing Status, emitting "none" for containers without a healthcheck instead of relying on Go's "<no value>" output which caused a template error and exit code 1. Agent-Logs-Url: https://github.com/blondres04/shieldclaw/sessions/ab4886d3-942a-46a1-8b93-4ebee24687e9 Co-authored-by: blondres04 <91551702+blondres04@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix timeout issue in docker_orchestrator.py health check
Fix May 4, 2026
_is_service_healthy nil-pointer crash for containers without a healthcheck
blondres04
marked this pull request as ready for review
May 4, 2026 02:09
There was a problem hiding this comment.
Pull request overview
Fixes a startup-time timeout in DockerOrchestrator._is_service_healthy when inspecting containers that have no configured Docker healthcheck (where .State.Health is nil), by making the docker inspect --format template nil-safe and updating tests accordingly.
Changes:
- Guard
.State.Health.Statusaccess in thedocker inspectGo template and emitnonewhen no healthcheck is configured. - Update the “no healthcheck” healthy-status check from
"<no value>"to"none". - Adjust unit tests’ mocked
docker inspectoutput to match the new template behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
shield-claw/src/shieldclaw/sandbox/docker_orchestrator.py |
Makes health/status inspection nil-safe and updates the accepted “no healthcheck” sentinel value. |
shield-claw/tests/test_docker_orchestrator.py |
Updates mocked docker inspect outputs to align with the new template (none\t...). |
Comments suppressed due to low confidence (1)
shield-claw/src/shieldclaw/sandbox/docker_orchestrator.py:536
docker inspectfailures are currently treated as “container not found” unconditionally (if result.returncode != 0: continue). This can still mask real Docker errors (e.g., daemon unavailable, permission denied, template/format issues) and cause_wait_for_compose_readyto spin until timeout with no actionable error. Consider checkingresult.stderrfor an actual “no such container/object” message before continuing; otherwise surface the error (raiseSandboxStartErroror at least log and returnFalseearly with the stderr detail).
"{{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}\t{{.State.Status}}",
container,
]
_LOG.debug("Running command: %s", cmd)
try:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
blondres04
pushed a commit
that referenced
this pull request
May 4, 2026
…able timeout) Unify resolve_compose_start_wait_seconds to read SHIELDCLAW_COMPOSE_START_TIMEOUT (same env var as main's _compose_start_timeout) so both code paths honour the same CI override. Update unit test to use the unified env var name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Containers without a configured healthcheck have
.State.Health == nil. The previousdocker inspecttemplate{{.State.Health.Status}}dereferenced this directly, causing Docker to exit 1 withnil pointer evaluating *types.Health.Status. The orchestrator treated every non-zero exit as "container not found" and kept retrying until the 120 s timeout.Changes
docker_orchestrator.py— Replace the flat template with a conditional that guards the nil dereference:Update the healthy-status check to accept
"none"(emitted by the new template) instead of"<no value>"(the Go template zero-value string, which was never actually reachable given the crash).tests/test_docker_orchestrator.py— Update mockeddocker inspectoutput in the no-healthcheck test cases from"<no value>\t..."to"none\t..."to match what the new template actually emits.Original prompt
This pull request was created from Copilot chat.