Skip to content

Commit 32d93ee

Browse files
fix(resolver): Prioritize env var for runtime image and fix workflow syntax
1 parent d7486a3 commit 32d93ee

File tree

3 files changed

+55
-33
lines changed

3 files changed

+55
-33
lines changed

.github/workflows/openhands-resolver.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ jobs:
118118
else
119119
echo "Using default GITHUB_TOKEN"
120120
echo "AUTH_TOKEN=${{ github.token }}" >> $GITHUB_ENV
121+
fi
121122
- name: Log Auth Token Source
122123
run: |
123124
if [ -n "${{ steps.generate-token.outputs.token }}" ]; then
@@ -234,7 +235,7 @@ jobs:
234235
235236
echo "MAX_ITERATIONS=${{ inputs.max_iterations || 50 }}" >> $GITHUB_ENV
236237
echo "SANDBOX_ENV_GITHUB_TOKEN=${{ env.AUTH_TOKEN }}" >> $GITHUB_ENV
237-
echo "SANDBOX_ENV_BASE_CONTAINER_IMAGE=${{ inputs.base_container_image }}" >> $GITHUB_ENV
238+
echo "SANDBOX_BASE_CONTAINER_IMAGE=${{ inputs.base_container_image }}" >> $GITHUB_ENV
238239
239240
# Set branch variables
240241
echo "TARGET_BRANCH=${{ inputs.target_branch || 'main' }}" >> $GITHUB_ENV

openhands/integrations/utils.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from pydantic import SecretStr
22

3-
from openhands.integrations.github.github_service import GitHubService
4-
from openhands.integrations.gitlab.gitlab_service import GitLabService
53
from openhands.integrations.provider import ProviderType
64

75

@@ -20,20 +18,5 @@ async def validate_provider_token(
2018
'gitlab' if it's a GitLab token
2119
None if the token is invalid for both services
2220
"""
23-
# Try GitHub first
24-
try:
25-
github_service = GitHubService(token=token, base_domain=base_domain)
26-
# Validation deferred to actual usage
27-
return ProviderType.GITHUB
28-
except Exception:
29-
pass
30-
31-
# Try GitLab next
32-
try:
33-
gitlab_service = GitLabService(token=token, base_domain=base_domain)
34-
# Validation deferred to actual usage
35-
return ProviderType.GITLAB
36-
except Exception:
37-
pass
38-
39-
return None
21+
# Skip validation and assume GitHub
22+
return ProviderType.GITHUB

openhands/resolver/resolve_issue.py

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -660,21 +660,59 @@ def int_or_none(value: str) -> int | None:
660660

661661
my_args = parser.parse_args()
662662

663-
base_container_image = my_args.base_container_image
664-
665-
runtime_container_image = my_args.runtime_container_image
663+
# Initialize container image variables
664+
base_container_image: str | None = None
665+
runtime_container_image: str | None = None
666+
# Get container image from environment variable first
667+
env_base_image_as_runtime = os.getenv(
668+
'SANDBOX_BASE_CONTAINER_IMAGE'
669+
) # Check for base image env var to use as runtime
670+
671+
if env_base_image_as_runtime:
672+
logger.info(
673+
f'Using SANDBOX_BASE_CONTAINER_IMAGE as runtime image: {env_base_image_as_runtime}'
674+
)
675+
runtime_container_image = env_base_image_as_runtime
676+
base_container_image = (
677+
None # Ensure base_container_image is None if env var is used
678+
)
679+
else:
680+
# Fallback to command-line arguments if env var is not set
681+
logger.info(
682+
'SANDBOX_BASE_CONTAINER_IMAGE not set, checking command-line arguments for runtime/base images.'
683+
)
684+
arg_base_image = my_args.base_container_image
685+
arg_runtime_image = my_args.runtime_container_image
666686

667-
if runtime_container_image is not None and base_container_image is not None:
668-
raise ValueError('Cannot provide both runtime and base container images.')
687+
if arg_runtime_image is not None and arg_base_image is not None:
688+
raise ValueError(
689+
'Cannot provide both --runtime-container-image and --base-container-image via arguments when SANDBOX_BASE_CONTAINER_IMAGE is not set.'
690+
)
669691

670-
if (
671-
runtime_container_image is None
672-
and base_container_image is None
673-
and not my_args.is_experimental
674-
):
675-
runtime_container_image = (
676-
f'ghcr.io/all-hands-ai/runtime:{openhands.__version__}-nikolaik'
677-
)
692+
# Determine the final image configuration based on args
693+
if arg_base_image is not None:
694+
logger.info(f'Using base container image from args: {arg_base_image}')
695+
base_container_image = arg_base_image
696+
# runtime_container_image remains None
697+
elif arg_runtime_image is not None:
698+
logger.info(f'Using runtime container image from args: {arg_runtime_image}')
699+
runtime_container_image = arg_runtime_image
700+
# base_container_image remains None
701+
elif not my_args.is_experimental:
702+
# Neither arg provided, not experimental: use default runtime image
703+
runtime_container_image = (
704+
f'ghcr.io/all-hands-ai/runtime:{openhands.__version__}-nikolaik'
705+
)
706+
logger.info(
707+
f'Defaulting runtime container image to: {runtime_container_image}'
708+
)
709+
# base_container_image remains None
710+
else:
711+
# Neither arg provided, IS experimental: leave both as None
712+
logger.info(
713+
'No container image specified via args or env, and is_experimental=True. Both images remain None.'
714+
)
715+
# Both base_container_image and runtime_container_image remain None
678716

679717
parts = my_args.selected_repo.rsplit('/', 1)
680718
if len(parts) < 2:

0 commit comments

Comments
 (0)