fix(agentfield): add test for issue #624 - #834
Draft
Salomondiei08 wants to merge 1 commit into
Draft
Conversation
Ref: Agent-Field#624 Signed-off-by: Jay <sallomondiei@gmail.com>
|
Jay seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to add regression coverage in the Python SDK for issue #624 (“Unexpected internal endpoints probe on start”) by asserting that creating an Agent with an explicit Kubernetes callback_url does not trigger external IP/metadata probing during startup.
Changes:
- Adds a new regression test that patches container detection and captures outbound
requests.getcalls duringAgentinitialization. - Asserts no HTTP requests are made when
callback_urlis explicitly provided.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+9
to
+31
| def test_issue_624(monkeypatch): | ||
| """An explicit Kubernetes callback URL must avoid metadata and ipify probes.""" | ||
| requests_made = [] | ||
|
|
||
| class DummyResponse: | ||
| status_code = 404 | ||
| text = "" | ||
|
|
||
| def fake_get(url, *args, **kwargs): | ||
| requests_made.append(url) | ||
| return DummyResponse() | ||
|
|
||
| monkeypatch.setattr(agent_mod, "_is_running_in_container", lambda: True) | ||
| monkeypatch.setattr(requests, "get", fake_get) | ||
|
|
||
| Agent( | ||
| node_id="issue-624-agent", | ||
| callback_url="http://issue-624-agent.default.svc.cluster.local:8001", | ||
| auto_register=False, | ||
| enable_did=False, | ||
| ) | ||
|
|
||
| assert requests_made == [] |
Comment on lines
+1
to
+6
| """Regression test for issue #624 — startup must not probe external IP services.""" | ||
|
|
||
| import requests | ||
|
|
||
| from agentfield import Agent | ||
| from agentfield import agent as agent_mod |
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.
What
Adds test coverage for the behavior described in issue #624.
Why
Fixes #624
Testing