Skip to content

.NET: Python: [Bug]: Declarative HTTP action drops existing URL query parameters #7749

Description

Description

Description

When a declarative HTTP request supplies both:

  • A URL that already contains query parameters
  • Additional values through query_parameters

the parameters already present in the URL are silently removed.

For example, this intended request:

https://api.example.test/items?api-version=2025-01-01&tenant=alpha&page=2

is sent as:

https://api.example.test/items?page=2

This can cause otherwise valid API requests to fail or target the wrong API version or tenant.

What I expected

Parameters supplied through query_parameters should be appended to the URL while preserving parameters already present in the URL.

Steps to reproduce

  1. Create a DefaultHttpRequestHandler.
  2. Use a URL containing one or more query parameters.
  3. Supply another parameter through HttpRequestInfo.query_parameters.
  4. Send the request and inspect the resulting URL.
  5. Observe that the original URL parameters are missing.

Code Sample

import asyncio

import httpx
from agent_framework_declarative import (
    DefaultHttpRequestHandler,
    HttpRequestInfo,
)


async def main() -> None:
    captured_urls: list[str] = []

    def respond(request: httpx.Request) -> httpx.Response:
        captured_urls.append(str(request.url))
        return httpx.Response(200, text="ok")

    async with httpx.AsyncClient(
        transport=httpx.MockTransport(respond),
    ) as client:
        handler = DefaultHttpRequestHandler(client=client)

        await handler.send(
            HttpRequestInfo(
                method="GET",
                url=(
                    "https://api.example.test/items"
                    "?api-version=2025-01-01&tenant=alpha"
                ),
                query_parameters={"page": "2"},
            )
        )

    print(captured_urls[0])


asyncio.run(main())


Actual output:


https://api.example.test/items?page=2


Expected output:


https://api.example.test/items?api-version=2025-01-01&tenant=alpha&page=2

Error Messages / Stack Traces

No exception is raised. The request is sent successfully with an incorrect URL.

Package Versions

agent-framework-declarative: 1.0.1

Python Version

Python 3.12.10

Additional Context

The equivalent .NET declarative HTTP handler preserves the existing query string when additional query parameters are supplied.

Custom HTTP request handlers may be unaffected. The issue reproduces with the default Python handler.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .NetdeclarativeUsage: [Issues, PRs], Target: declarative agents and workflowspythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions