Compare commits

..

4 Commits

Author SHA1 Message Date
openhands
51d1a993fb Revert "Add RecallActions and observations for retrieval of prompt extensions (#6909)"
This reverts commit cc45f5d9c3.
2025-03-16 02:51:57 +00:00
Engel Nyst
cc45f5d9c3 Add RecallActions and observations for retrieval of prompt extensions (#6909)
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: Calvin Smith <email@cjsmith.io>
2025-03-15 21:48:37 +01:00
tofarr
e34a771e66 Fix for issue where initial command fails (#7254) 2025-03-14 14:49:57 -06:00
tofarr
ec763f8105 Fix for error where credits is accessed even when billing is disabled (#7250) 2025-03-14 15:10:54 +00:00
6 changed files with 9 additions and 71 deletions

View File

@@ -4,8 +4,10 @@ import userEvent from "@testing-library/user-event";
import { afterEach, beforeEach, describe, expect, it, test, vi } from "vitest";
import OpenHands from "#/api/open-hands";
import { PaymentForm } from "#/components/features/payment/payment-form";
import * as featureFlags from "#/utils/feature-flags";
describe("PaymentForm", () => {
const billingSettingsSpy = vi.spyOn(featureFlags, "BILLING_SETTINGS");
const getBalanceSpy = vi.spyOn(OpenHands, "getBalance");
const createCheckoutSessionSpy = vi.spyOn(OpenHands, "createCheckoutSession");
const getConfigSpy = vi.spyOn(OpenHands, "getConfig");
@@ -26,6 +28,7 @@ describe("PaymentForm", () => {
GITHUB_CLIENT_ID: "123",
POSTHOG_CLIENT_KEY: "456",
});
billingSettingsSpy.mockReturnValue(true);
});
afterEach(() => {

View File

@@ -1,6 +1,7 @@
import { useQuery } from "@tanstack/react-query";
import { useConfig } from "./use-config";
import OpenHands from "#/api/open-hands";
import { BILLING_SETTINGS } from "#/utils/feature-flags";
export const useBalance = () => {
const { data: config } = useConfig();
@@ -8,6 +9,6 @@ export const useBalance = () => {
return useQuery({
queryKey: ["user", "balance"],
queryFn: OpenHands.getBalance,
enabled: config?.APP_MODE === "saas",
enabled: config?.APP_MODE === "saas" && BILLING_SETTINGS(),
});
};

View File

@@ -1,6 +1,6 @@
{% if repository_info %}
<REPOSITORY_INFO>
At the user's request, repository {{ repository_info.repo_name }} has been cloned to directory {{ repository_info.repo_directory }}.
At the user's request, repository {{ repository_info.repo_name }} has been cloned to the current working directory {{ repository_info.repo_directory }}.
</REPOSITORY_INFO>
{% endif %}
{% if repository_instructions -%}

View File

@@ -27,7 +27,7 @@ class GithubIssueHandler(IssueHandlerInterface):
def get_headers(self) -> dict[str, str]:
return {
'Authorization': f'Bearer {self.token}',
'Authorization': f'token {self.token}',
'Accept': 'application/vnd.github.v3+json',
}
@@ -450,7 +450,7 @@ class GithubPRHandler(GithubIssueHandler):
"""Download comments for a specific pull request from Github."""
url = f'https://api.github.com/repos/{self.owner}/{self.repo}/issues/{pr_number}/comments'
headers = {
'Authorization': f'Bearer {self.token}',
'Authorization': f'token {self.token}',
'Accept': 'application/vnd.github.v3+json',
}
params = {'per_page': 100, 'page': 1}

View File

@@ -1,66 +0,0 @@
import pytest
from unittest.mock import patch, MagicMock
from openhands.resolver.interfaces.github import GithubIssueHandler, GithubPRHandler
@pytest.mark.asyncio
async def test_github_issue_handler_auth_headers():
"""Test that GithubIssueHandler uses Bearer token in authorization headers."""
# Create a GithubIssueHandler instance
handler = GithubIssueHandler(
owner="test-owner",
repo="test-repo",
token="test-token",
username="test-username"
)
# Check that the headers use Bearer token
headers = handler.get_headers()
assert headers["Authorization"] == "Bearer test-token"
# Mock requests.get to check headers in API calls
with patch("requests.get") as mock_get:
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = []
mock_get.return_value = mock_response
# Call a method that uses requests.get
handler.download_issues()
# Check that the call to requests.get used Bearer token
call_args = mock_get.call_args
headers_used = call_args[1]["headers"]
assert headers_used["Authorization"] == "Bearer test-token"
@pytest.mark.asyncio
async def test_github_pr_handler_auth_headers():
"""Test that GithubPRHandler uses Bearer token in authorization headers."""
# Create a GithubPRHandler instance
handler = GithubPRHandler(
owner="test-owner",
repo="test-repo",
token="test-token",
username="test-username"
)
# Check that the headers use Bearer token
headers = handler.get_headers()
assert headers["Authorization"] == "Bearer test-token"
# Mock requests.post to check headers in GraphQL API calls
with patch("requests.post") as mock_post:
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"data": {"repository": {"pullRequest": {}}}}
mock_post.return_value = mock_response
# Call a method that uses requests.post with GraphQL
handler.download_pr_metadata(1)
# Check that the call to requests.post used Bearer token
call_args = mock_post.call_args
headers_used = call_args[1]["headers"]
assert headers_used["Authorization"] == "Bearer test-token"

View File

@@ -117,7 +117,7 @@ def test_prompt_manager_template_rendering(prompt_dir):
msg_content: str = initial_msg.content[0].text
assert '<REPOSITORY_INFO>' in msg_content
assert (
"At the user's request, repository owner/repo has been cloned to directory /workspace/repo."
"At the user's request, repository owner/repo has been cloned to the current working directory /workspace/repo."
in msg_content
)
assert '</REPOSITORY_INFO>' in msg_content