fix(aimlapi): send attribution headers on every aimlapi.com request (#17491)

### Summary

The **aimlapi.com** provider added in #17311 does not identify itself on
any of its outgoing requests, so its traffic cannot be attributed to the
integration. This PR adds the two headers AIMLAPI expects —
`X-AIMLAPI-Source` and `X-AIMLAPI-Partner-ID` — to every request the
provider makes.
This commit is contained in:
Eugene
2026-07-28 18:22:27 +03:00
committed by GitHub
parent 9460e6ba03
commit c1e1d012bb
7 changed files with 119 additions and 5 deletions

View File

@@ -0,0 +1,32 @@
from common.aimlapi_utils import DEFAULT_PARTNER_ID, DEFAULT_SOURCE, attribution_headers, partner_id, source
def test_defaults(monkeypatch):
monkeypatch.delenv("AIMLAPI_SOURCE", raising=False)
monkeypatch.delenv("AIMLAPI_PARTNER_ID", raising=False)
assert source() == DEFAULT_SOURCE
assert attribution_headers() == {
"X-AIMLAPI-Source": DEFAULT_SOURCE,
"X-AIMLAPI-Partner-ID": DEFAULT_PARTNER_ID,
}
def test_environment_overrides(monkeypatch):
monkeypatch.setenv("AIMLAPI_SOURCE", " agent/custom ")
monkeypatch.setenv("AIMLAPI_PARTNER_ID", " part_custom ")
assert source() == "agent/custom"
assert partner_id() == "part_custom"
assert attribution_headers() == {
"X-AIMLAPI-Source": "agent/custom",
"X-AIMLAPI-Partner-ID": "part_custom",
}
def test_blank_partner_id_is_omitted(monkeypatch):
monkeypatch.delenv("AIMLAPI_SOURCE", raising=False)
monkeypatch.setenv("AIMLAPI_PARTNER_ID", " ")
headers = attribution_headers()
assert headers == {"X-AIMLAPI-Source": DEFAULT_SOURCE}