Repository navigation
chore: merge main into v1 (DO NOT SQUASH, lands by fast-forward) - #1262
Conversation
…1230) clean() turned set, list and tuple values into lists but sent frozenset and deque values as None, so those properties were silently lost.
…e-ai-crewai in the uv group across 1 directory (#1241) chore(deps): bump langgraph Bumps the uv group with 1 update in the /examples/example-ai-langgraph directory: [langgraph](https://github.com/langchain-ai/langgraph). Updates `langgraph` from 1.2.12 to 1.2.14 - [Release notes](https://github.com/langchain-ai/langgraph/releases) - [Commits](langchain-ai/langgraph@1.2.12...1.2.14) --- updated-dependencies: - dependency-name: langgraph dependency-version: 1.2.14 dependency-type: direct:production dependency-group: uv ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat(emails): let a code send turn off open and click tracking Adds track_opens_and_clicks to the code form of emails.send. False sends the email without PostHog's open pixel and rewritten links. The field goes into the request body only when the caller sets it, so a default send keeps today's body. The template form refuses it, like capture_engagement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(emails): say track_opens_and_clicks only removes the open pixel PostHog never rewrites the links of an email sent from code, so it counts no clicks either way. False removes the open pixel only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(emails): let a code send choose its tracking Replace track_opens_and_clicks with tracking: True, False, or an EmailTracking dict of opens, clicks and engagement. Leave tracking and capture_engagement out of the body unless the caller sets them, so the API can refuse a send that sets both. Deprecate capture_engagement. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): prove the tracking choice over real HTTP Send each tracking form through the public send API to a local HTTP server and assert the body it receives, instead of a stubbed transport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(emails): let a code send mark its email sensitive A code send now takes an optional `sensitive`, sent only when set. Without it, PostHog keeps today's behavior: a send whose template_key matches a saved template follows that template, and any other send is sensitive. Click tracking follows it unless `tracking` sets clicks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…1226) * test(mcp): failing repro for FastMCP tool failures losing the raised exception Standalone FastMCP converts a raised tool exception into an isError result before our wrapped handler returns, so the failure is reported as a generic "Error" with no frames (posthog-python#1223). Fails on fastmcp 3/mcp 1 and fastmcp 4/mcp 2. * fix(mcp): report the exception behind a FastMCP isError tool result Standalone FastMCP converts a raised tool exception into CallToolResult(isError=True) inside the tools/call handler we wrap, so every failure was captured from the result text: $mcp_error_type "Error", one generic $exception_list entry, no frames (posthog-python#1223). instrument() now wraps the server's public call_tool, which still raises (ToolError chained from the tool's exception). The wrapper hands the outermost call's outcome to the enclosing handler through a context variable, and the handler records it next to the result. fastmcp's "Error calling tool" ToolError joins the dispatch wrappers the scalars step past, so $mcp_error_type names the tool's own exception. Tested: - test_fastmcp_tool_errors.py fails before, passes after, on fastmcp 3.2 + mcp 1.30 and fastmcp 4.1.8 + mcp 2.3 - pytest posthog/test/mcp: 694 passed (mcp 1.x), 575 passed (mcp 2.x) - issue repro: $mcp_error_type RuntimeError, chain ToolError -> RuntimeError -> ConnectionError with frames - ruff format/check, mypy clean Not included: $mcp_error_status. The taxonomy defines it as the upstream status of PostHog's own server calls and no SDK sets it today; setting it from the SDK is a cross-SDK contract change. * fix(mcp): keep another server's handled tool failure off this call Pre-PR gate findings on the previous commit: - The error slot was shared across servers. A tool that called another instrumented FastMCP's call_tool and handled its failure got that exception on its own successful event, whenever its own server's call_tool was not wrapped (a raw low-level server, or a FastMCP instrumented only through _mcp_server). The slot now names the server whose handler opened it, and only that server's call_tool writes to it. - The "Error calling tool" wrapper match also unwrapped a tool's own ToolError worded that way. It now requires fastmcp's quoted tool name. Tested: both repros added to test_fastmcp_tool_errors.py; pytest posthog/test/mcp 697 passed (mcp 1.30 + fastmcp 3.2), 578 passed (mcp 2.3 + fastmcp 4.1.8); ruff and mypy clean. * fix(mcp): keep FastMCP 2.x instrumented, and freeze the slot on exit Review on 81b3170 (PostHog Review, confirmed by ioannisj): - FastMCP 2.x has no public call_tool, so wrapping it raised AttributeError and instrument() fell back to no-op analytics: no MCP events at all on a supported stack. 2.x dispatches tools/call through _call_tool_middleware, so that is the seam wrapped there. 2.x now also reports the raised exception. - A background task holding the slot could settle it after the handler's dispatch returned. The slot now closes when the handler leaves it. - CI gains a v1-fastmcp2 leg (mcp 1.x + fastmcp 2.x), which would have caught the first point. Tested: pytest posthog/test/mcp passes on fastmcp 2.14.7 + mcp 1.30, fastmcp 3.2 + mcp 1.30, fastmcp 4.1.8 + mcp 2.3 (at 81b3170, 63 tests failed on fastmcp 2.14.7; at ae8f0bd all passed). The background race did not reproduce in a 0-40 tick sweep on 3.2 or 4.1.8, so it has no test; the close-on-exit makes it impossible by construction. * fix(mcp): redact secrets in captured exception frame source lines The MCP sanitizer scrubbed each exception's value but not its frames' pre_context, context_line and post_context. A token written in the source around a raise reached $exception verbatim. This was already true on the official SDK path; #1223's fix made it reachable on standalone FastMCP too, where frames were never sent before. Those three keys now pass through the same sanitize_captured_value as the value. Tested: test_secrets_in_frame_source_lines_are_redacted fails without the sanitizer change and passes with it; full MCP suites pass on fastmcp 2.14.7, 3.2 and 4.1.8. * fix(mcp): don't let a lingering background task keep a tool's traceback alive PostHog Review on 34fbaeb: a background task started by a failing tool copies the request's context, and with it the slot holding the raised exception. Closing the slot left the exception attached, so its traceback and every frame's locals lived as long as the task. The slot the context can reach is now emptied on exit; the handler reads the outcome from a separate object only it holds. Tested: test_a_background_task_does_not_keep_the_failure_alive holds a weakref to a tool local while the tool's background task is still pending. It fails before and passes after on fastmcp 2.14.7, 3.2 and 4.1.8. The test turns logging off, because pytest's log capture keeps fastmcp's error records and their exc_info would retain the traceback by itself. Full MCP suites: 690 / 699 / 580 passed. * fix(mcp): redact sensitive JSON members inside captured strings Review on 52fc421 (PostHog Review, dustinbyrne): a failed FastMCP tool whose source has `credentials = {"password": "hunter2"}` sent the password in its frame's source context. The cause is wider than frames: the MCP Payload privacy spec requires redacting, inside any captured string, the value of a JSON member whose key is on the credential list, and posthog-python never implemented it. posthog-go and posthog-rs do. This ports their pattern into _redact_credentials, so it covers response text, error messages and frame source alike. Tested: posthog-go's TestSanitizeStringRedactsSensitiveJSONMembers table ported as a parameterized test, plus a source-line case; 13 redaction cases failed before, all 17 pass after. The frame test now also carries a JSON credential next to a benign member that must survive. Full MCP suites pass: 716 (fastmcp 3.2 + mcp 1.30), 597 (fastmcp 4.1.8 + mcp 2.3), 707 (fastmcp 2.14.7 + mcp 1.30). Ruff and mypy clean. * fix(mcp): keep JSON-member redaction linear on malformed arrays Review on d8a7a55 (PostHog Review, veria-ai): the array part of the JSON-member pattern made every comma optional. Go and Rust run that pattern on linear-time engines; Python's re backtracks, so a caller's `{"note":[` + 40 digits + `!` split the digits into array items in exponentially many ways and blocked the event loop. Every item after the first now needs its comma, with an optional trailing one so an array cut off mid-list still matches, which leaves each input one parse. Tested: test_json_member_redaction_runs_in_linear_time_on_malformed_arrays timed out at 5 s on two of three inputs before and passes after. Ten adversarial 100k-character shapes (open arrays, lone quotes, unclosed strings, escapes, number characters) each finish under 10 ms. All JSON-member cases still pass. Full MCP suites: 719 / 600 / 710 passed on fastmcp 3.2 / 4.1.8 / 2.14.7. * fix(mcp): scan JSON members once instead of retrying the regex at every quote Review on 9c1cb4f (PostHog Review, veria-ai): with no member to match, the JSON-member regex restarted at every quote and rescanned the rest of the text, so 16,000 escaped quote pairs took about 3 s and 64,000 took 49 s on the server's event loop. This is the second performance finding in that regex: Go and Rust run it on linear-time engines, and Python's re does not. It is replaced by a scanner that tries the same key starts but caches where a string body ends and what follows each closing quote, so overlapping candidates share their work. Tested: the linear-time test gains escaped-quote and JSON-encoded-quote inputs at 32,000 pairs, which timed out at 5 s before and pass after; ten adversarial 100k-200k-character shapes each finish under 60 ms. A differential test keeps the reference pattern as an oracle and checks the scanner against it on 30,000 random texts (a one-off run of 200,000 longer ones found no mismatch). Full MCP suites: 722 / 603 / 713 passed on fastmcp 3.2 / 4.1.8 / 2.14.7; ruff and mypy clean.
…ain (#1229) * feat(mcp): set $mcp_error_status from the raised exception's cause chain MCP Analytics groups failed calls by $mcp_error_status, but only PostHog's own server set it, so every posthog.mcp failure landed in "unknown". Rootly asked for it in #1223. Walk the cause chain inward (__cause__, else __context__ unless suppressed) and take the first int 100-599 from status_code, statusCode or status on the exception or its response, per the sdk-specs Failure capture rule. A caller's properties still win. Tested: pytest posthog/test/mcp (720 passed, 11 skipped); new parameterized test_error_status.py covers chain shapes and rejected values; FastMCP end-to-end row raises httpx.HTTPStatusError(503) under mask_error_details=True. * fix(mcp): follow __cause__ whenever set, and cap the status walk at 50 links Pre-PR adversarial review found two gaps against the sdk-specs rule: a __cause__ left with __suppress_context__ False was skipped for __context__, and a chain whose links are built on read never ended. Walk the chain a traceback prints, capped at 50 links like $exception_list. Tested: pytest posthog/test/mcp (724 passed, 11 skipped); mypy baseline clean. * fix(mcp): type the status walk's seen set, and record ERROR_STATUS in the API snapshot CI on 68b8974 failed Mypy (var-annotated on `seen` in _exceptions.py) and the Public API snapshot check (the new PostHogMCPAnalyticsProperty.ERROR_STATUS constant), which PostHog Review also flagged. Tested: mypy | mypy-baseline filter clean; check_public_api.py up to date; pytest posthog/test/mcp 725 / 606 / 716 passed on fastmcp 3.2 + mcp 1.30, 4.1.8 + mcp 2.3, 2.14.7 + mcp 1.30.
…sults (#1231) * fix(mcp): report the raised exception on mcp 1.x low-level isError results On mcp 1.x the low-level @server.call_tool() decorator catches a tool's raise and returns CallToolResult(isError=True) before our handler sees it, so $mcp_tool_call had $mcp_error_type "Error", no frames and no $mcp_error_status (#1223). The decorator builds that result through server._make_error_result inside its except block, so an instance wrapper reads the live exception there and settles it into the same raised_tool_error slot standalone FastMCP uses. Validation failures also pass through that method inside an except block; only a message equal to str(exception) is the tool's own raise. mcp 2.x low-level needs no change: raw handlers raise through to our wrapper, and a scratch check showed RuntimeError, both frames and status 503. Tested: parameterized test in test_lowlevel.py (plain and wrapped 503, plain ValueError, input-validation guard). Red before on the three raising rows. Removing the message guard turns the validation row into ValidationError. pytest posthog/test/mcp: mcp 1.30 727 passed / 11 skipped; mcp 2.3 bare 551 passed / 55 skipped. CI-exact mypy: only the base branch's _exceptions.py:65. * chore(mcp): scope the low-level raise recovery note and changeset to what it covers Pre-PR review: the message guard admits any exception the decorator's catch-all sees (tool body, list_tools cache refresh, result construction), not only the tool's own raise, and _make_error_result first ships in mcp 1.10. Comment and changeset now say so. Tested: pytest posthog/test/mcp on mcp 1.30, 727 passed. * fix(mcp): tell validation results apart before rendering the exception Review on #1231 (PostHog Review, dustinbyrne): the message guard called str(error) on jsonschema ValidationErrors, which renders the whole instance and schema. On a deeply nested payload that raised RecursionError and replaced the SDK's validation response; on a large one it blocked the loop. A validation result is now matched by the prefix plus the error's own short .message first, and any failure while inspecting the exception leaves the original result untouched. A tool's own raise worded like a validation error is still recovered. Tested: parameterized test gains a 400-deep payload row (red before: response text 'maximum recursion depth exceeded') and a prefix-worded ValueError row. pytest posthog/test/mcp: mcp 1.30 730 passed / 11 skipped; mcp 2.3 bare 551 passed / 55 skipped. CI-exact mypy clean.
* feat: send email content from code with posthog.emails.send Squash of Silthus#2 at e5fdedf, re-signed for required signatures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: cut emails.send to the template and rendered code forms Parks the local-template form (template_data on a code send, the content hash, the upload by key and its retry) and the cc, bcc, headers, tags and attachments fields, to match posthog-node. A code send now takes rendered html and/or text only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): cover the async code-form send and migrated_from Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: send cc, bcc and attachments with emails.send A code send takes cc and bcc as one address or a list, and attachments as files with bytes or Base64 content. The client encodes bytes once, before any retry. A file it can't send raises EmailError with the code invalid_attachment and a field such as attachments__0__content, and the error never repeats the file's content. A template_id send refuses all three fields before any request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: refuse every unknown attachment key, a None key included next(..., None) used None as its no-match value, so a None key hid the unknown keys after it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: cover a None attachment key before an unknown one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: describe an older server's refusal without its error code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): leave reply_to out when the list is empty Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): refuse an attachment string that is not base64 A text file passed as a str was sent unchecked as if it were Base64. The client now raises invalid_attachment before any request and hints to pass the file's bytes instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(emails): name the refused-send test after what it guards Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(emails): drop a comment the name and test already state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(emails): give cc, bcc and attachments their own changeset The base PR owns emails-code-form.md, so this PR no longer edits it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): refuse an attachment with an empty filename Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(emails): upload attachments by hash, then send their references A code send hashes each file, asks PostHog which files it lacks, PUTs those straight to PostHog's file storage with the returned headers and without the secret key, then sends the email naming each file by its SHA-256. The client checks 10 files and the 40 MB message estimate before any request. A failed upload sends no email and surfaces the storage's answer. Part of PostHog/michaelr-context#81. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): send the storage upload exactly as signed An injected client's defaults leaked into the presigned PUT: httpx params replaced the URL's signature query, a requests session appended its params, and default headers rode along. The upload is now a standalone request with only the returned URL and headers, sent through the same transport and retries. Part of PostHog/michaelr-context#81. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): keep the environment's TLS settings and the signed URL private on uploads The standalone storage PUT skipped requests' environment merge, so a custom CA bundle or proxy applied to sends but not to uploads. It now merges the environment's transport settings, without session headers or auth. A storage network error is re-raised without its cause, so the presigned URL never reaches a traceback. Part of PostHog/michaelr-context#81. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): upload shared bytes once and retry a storage's passing faults - The client counts attachments before it reads any file. - Bytes that two attachments share go in the upload request once. - The upload parser returns only the uploads still to make, each with its attachment index. - A storage 500, 502 or 504 is retried like 503. - A refused upload no longer takes the names of PostHog's API statuses. - An unreachable storage raises network_error naming the attachment. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): retry a storage's 429 and name what the comments said The previous commit stopped retrying a storage 429, which the general rate-limit branch had retried. Storage 429 is retried again and named rate_limit_exceeded. Names replace the comments that commit added. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): name attachments when PostHog has no upload route A PostHog version without the upload route answered 404, and the send raised a bare not_found with no field. The docs promise that an older PostHog's refusal names the field. It now raises not_found with field attachments, a reason and a fix, and sends nothing. Tests now cover the names a storage fault gets once its retries run out. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): size attachments before copying them The client copied and hashed every file before it checked the message size. Ten views of one large buffer could exhaust memory before message_too_large. Each file is now sized from its buffer or its Base64 length, the estimate is checked, and only then are files read and hashed. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): size Base64 content by its data, not its padding Extra trailing padding decodes, so it must not shrink the estimate. Ticket: PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): pin each body's count in the size estimate The server counts html and text each like a file: UTF-8 bytes, Base64 with line breaks. Pin both bodies, their UTF-8 length and per-body rounding. Ticket: PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): report PostHog's own answer to an upload-route 404 A 404 can mean a PostHog without the upload route or sending from code off for the project, so keep the server's reason on attachments instead of naming one cause. Ticket: PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): say which Base64 the SDK takes and where a refused upload goes wrong A wrapped, unpadded or URL-safe string now learns it needs one padded line from base64.b64encode. A storage refusal points at a fresh send or a proxy, not at bytes the caller can't change. Ticket: PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): count the subject in the message estimate like the server The server now adds 75 bytes per 42 UTF-8 bytes of subject, so a long subject beside a near-limit file must be refused before the upload. Ticket: PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): check uploads against their signed checksum like real storage The fake storage now refuses a PUT whose bytes don't match the signed checksum and length, and each upload slot is signed for its own file. A new test asserts every file PostHog lacks lands in storage under its own hash. Refs PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): size padded Base64 without a copy and never follow a storage redirect Sizing a Base64 string no longer strips its padding into a new string, so refusing an oversized file allocates nothing the size of the file. The async upload passes follow_redirects=False, so an injected client that follows redirects can't turn a storage 302 into a GET that looks like a stored file. The subject's share of the size limit is now pinned through send instead of through a private helper. Refs PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): prove the async upload refuses a storage redirect over real sockets The redirect test now runs against a local HTTP server that answers the upload route, redirects the PUT and serves a login page, instead of a scripted transport. It asserts upload_failed and that the login page and the send route were never reached. Refs PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): test attachments against fakes that behave like PostHog and S3 The attachment tests now run against one in-memory PostHog with its file storage. The upload and send routes need the secret key and refuse fields outside their schema. Storage refuses a presigned PUT the way S3 does: an added query parameter, an Authorization header, an expired URL or bytes that don't match the signed checksum. A send delivers an email with the stored bytes and replays a repeated idempotency key. Tests assert the delivered email, the bucket and the EmailError, not request shapes. The CA test runs a real TLS handshake against a local storage server with a certificate made in the test. Refs PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): count the text PostHog derives and upload only over https Without text, PostHog derives the plain text from the HTML and counts it in the message size, so an HTML-only email near the limit uploaded its files and was then refused. The client now counts the HTML twice, since the derived text is never longer. A plain HTTP upload URL from misconfigured storage would carry the file and its signed URL unencrypted. The client now stops before any upload with api_error naming the attachment, unless the client's host is plain HTTP too, as in local development. The fake PostHog now checks each route's method and records the content type storage keeps. Tests assert stored files, not storage keys, and the tests that only exercised the fake are gone. Refs PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): name the caller's attachment in upload refusals and read storage answers whole An upload-route refusal named the wire field (files, files__1__size), which the caller never passed. It now names attachments, or the first attachment holding that file. A session with stream=True left a storage answer unread until after the upload, so a cut-off answer lost its attachment; the storage request now always reads the answer at once. The cc and bcc tests now assert the recipients of the delivered email, and the template-content tests are back to main's shape. Refs PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): serve the test's TLS storage at TLS 1.2 or later CodeQL flags the local HTTPS storage server's SSLContext for allowing TLS 1.0 and 1.1. Pin the minimum version. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): assert outcomes, not request traces, in the real-socket upload tests The redirect and cut-short storage tests compared the server's request list, which held the storage object path. They now assert the caller's error, that no email was sent, and that the redirect was never followed. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): run the field refusal and size tests against the PostHog fake The cc refusal test now sends to a PostHog that doesn't take cc and asserts the caller's error and that nothing was delivered, instead of counting requests on a canned transport. The two oversized-email tests assert that nothing was stored or delivered. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): prove an upload never follows storage to another server A client that follows a 307 or 308 on the PUT sends the file again to the new URL, even over plain HTTP, and reports success. Both upload paths already refuse redirects. New sync and async tests have the storage answer 307 to a plain-HTTP server and assert upload_failed on the attachment without either URL, that the other server received nothing, and that no email was sent. Without the fix, requests and an httpx client with follow_redirects deliver the file there. The docs and changeset say the client never follows a redirect. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): name the lost-reply retry test for what it proves The test shows a send retried after a lost reply replays with its idempotency key. It can't observe whether uploads are asked for again, so the name no longer promises that. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(emails): refuse extra Base64 padding before copying the string The size check walked back over any number of trailing "=", so a short Base64 string followed by tens of millions of "=" passed as a few bytes, and b64decode then copied and scanned all of it, blocking the async client's event loop. Standard Base64 has at most two "=", so a third now raises invalid_attachment with the Base64 advice during that walk, before any copy. The extra-padding size case is refused this way now. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(emails): name a failed attachment upload attachment_upload_failed Go, JS, Ruby and PHP raise attachment_upload_failed for a refused or redirected upload, and the docs list one code for every SDK. The code was upload_failed only in this unreleased change, so it takes the shared name in the error, the tests, the docstrings and the changeset. PostHog/michaelr-context#81 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(emails): follow a storage 307 to another server over real sockets The two cross-server redirect tests now run against a local PostHog whose storage answers the upload with a 307 to a second local server. They assert the second server receives nothing and no email is sent, instead of injecting the redirect through mocked transports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* chore: remove mutation testing setup * refactor: reduce SDK complexity and correct CRAP scoring * test: isolate MCP cancellation from optional version helpers
* fix: treat failed feature flag records as unevaluated * test: expect no result for failed flag attribution * test: update released comparisons for failed flag records * fix: use qualified PyPI package in flag changeset * fix(flags): preserve unresolved reasons for failed fallback * fix(flags): clarify failed-record classification and regression coverage * fix(flags): preserve failed snapshot diagnostics * ci: upgrade SDK compliance harness to 1.31.1
…ges (#1251) * docs: publish the posthog-python 8.x reference and migration guide pages Adds references/posthog-python-8.md and references/posthog-python-migration.md as the 8.0.0 release will write them, so the Strapi sync puts them on posthog.com before 8.0.0 ships. Both come from running bin/docs on docs/migration-guide-structure (#1245) with posthog/version.py at 8.0.0, the version the release sets before it generates. The generator on main writes only the 7.x page and the reference page, and skips the migration page without docs/migration-*.md, so neither file is rewritten before the release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: regenerate the migration page from the guide's latest fix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs: regenerate the migration page without the 404 hint and self-hosted lines Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Bumps [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python) from 1.45.1 to 1.45.2. - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) --- updated-dependencies: - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
) Bumps the uv group with 1 update in the /examples/example-ai-autogen directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-llamaindex directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-semantic-kernel directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-smolagents directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) --- updated-dependencies: - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…1255) Bumps the uv group with 1 update in the /examples/example-ai-anthropic directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-aws-bedrock directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-azure-openai directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-cerebras directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-cloudflare-ai-gateway directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-cohere directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-dedalus directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-deepseek directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-fireworks-ai directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-gemini directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-groq directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-helicone directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-hugging-face directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-instructor directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-langchain directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-langgraph directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-mirascope directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-mistral directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-ollama directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-openai directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-openrouter directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-perplexity directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-portkey directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-together-ai directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-vercel-ai-gateway directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Bumps the uv group with 1 update in the /examples/example-ai-xai directory: [opentelemetry-api](https://github.com/open-telemetry/opentelemetry-python). Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) Updates `opentelemetry-api` from 1.45.1 to 1.45.2 - [Release notes](https://github.com/open-telemetry/opentelemetry-python/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md) - [Commits](open-telemetry/opentelemetry-python@v1.45.1...v1.45.2) --- updated-dependencies: - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv - dependency-name: opentelemetry-api dependency-version: 1.45.2 dependency-type: indirect dependency-group: uv ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ry output block (#1256) The Claude Code CLI sends each content block of a response as its own AssistantMessage, and each tool result as its own UserMessage after the generation's message_stop. The processor and PostHogClaudeSDKClient replaced the pending output on every AssistantMessage and promoted queued input at message_stop, so a generation kept only its last output block and the generation after a tool call had no $ai_input. Append output blocks per generation, append tool results to the queued input, and promote queued input when the next main-agent generation starts. A generation with nothing queued still has no input, as before. A request that is restarted before its message_stop drops its partial output. Without stream events, the result fallback reports every block of the final assistant turn. Messages a subagent sends (parent_tool_use_id set) stay out of the main generations' content.
) fix(ai): record the status of an Anthropic stream error event instead of 200 Anthropic sends errors that happen after a stream starts, such as overloaded_error, as an SSE error event, and the anthropic SDK raises them with the stream response's 200 status. Map the error type to its documented HTTP status (0 when unknown) so these failures are not recorded as a 200.
#1249) messages.stream() wrapped the manager's request without a try/except, so a failed initial request (401, connection error) raised without any $ai_generation error event, unlike create(stream=True). Capture the error in both sync and async clients and re-raise.
Bumps the github-actions group with 5 updates: | Package | From | To | | --- | --- | --- | | [actions/setup-python](https://github.com/actions/setup-python) | `7.0.0` | `7.1.0` | | [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) | `10.3.0` | `10.3.3` | | [github/codeql-action/init](https://github.com/github/codeql-action) | `4.39.2` | `4.39.3` | | [github/codeql-action/analyze](https://github.com/github/codeql-action) | `4.39.2` | `4.39.3` | | [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) | `8.1.1` | `8.1.2` | Updates `actions/setup-python` from 7.0.0 to 7.1.0 - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v7...6d4fd22) Updates `astral-sh/setup-uv` from 10.3.0 to 10.3.3 - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](astral-sh/setup-uv@v10.3.0...68559e9) Updates `github/codeql-action/init` from 4.39.2 to 4.39.3 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@1fc58d0...33d7b85) Updates `github/codeql-action/analyze` from 4.39.2 to 4.39.3 - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@1fc58d0...33d7b85) Updates `peter-evans/create-pull-request` from 8.1.1 to 8.1.2 - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](peter-evans/create-pull-request@5f6978f...15733db) --- updated-dependencies: - dependency-name: actions/setup-python dependency-version: 7.1.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: github-actions - dependency-name: astral-sh/setup-uv dependency-version: 10.3.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: github/codeql-action/init dependency-version: 4.39.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: github/codeql-action/analyze dependency-version: 4.39.3 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions - dependency-name: peter-evans/create-pull-request dependency-version: 8.1.2 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the ai-providers group with 9 updates: | Package | From | To | | --- | --- | --- | | [langchain](https://github.com/langchain-ai/langchain) | `1.4.7` | `1.4.9` | | [anthropic](https://github.com/anthropics/anthropic-sdk-python) | `1.13.0` | `2.6.0` | | [langgraph](https://github.com/langchain-ai/langgraph) | `1.2.16` | `1.2.20` | | [langchain-core](https://github.com/langchain-ai/langchain) | `1.6.13` | `1.7.6` | | [langchain-openai](https://github.com/langchain-ai/langchain) | `1.7.2` | `1.7.4` | | [langchain-anthropic](https://github.com/langchain-ai/langchain) | `1.7.6` | `1.7.10` | | [google-genai](https://github.com/googleapis/python-genai) | `2.32.0` | `2.33.0` | | [langchain-protocol](https://github.com/langchain-ai/agent-protocol) | `0.0.20` | `0.0.21` | | [openai](https://github.com/openai/openai-python) | `2.54.0` | `3.46.0` | Updates `langchain` from 1.4.7 to 1.4.9 - [Release notes](https://github.com/langchain-ai/langchain/releases) - [Commits](langchain-ai/langchain@langchain==1.4.7...langchain==1.4.9) Updates `anthropic` from 1.13.0 to 2.6.0 - [Release notes](https://github.com/anthropics/anthropic-sdk-python/releases) - [Changelog](https://github.com/anthropics/anthropic-sdk-python/blob/main/CHANGELOG.md) - [Commits](anthropics/anthropic-sdk-python@v1.13.0...v2.6.0) Updates `langgraph` from 1.2.16 to 1.2.20 - [Release notes](https://github.com/langchain-ai/langgraph/releases) - [Commits](langchain-ai/langgraph@1.2.16...1.2.20) Updates `langchain-core` from 1.6.13 to 1.7.6 - [Release notes](https://github.com/langchain-ai/langchain/releases) - [Commits](langchain-ai/langchain@langchain-core==1.6.13...langchain-core==1.7.6) Updates `langchain-openai` from 1.7.2 to 1.7.4 - [Release notes](https://github.com/langchain-ai/langchain/releases) - [Commits](langchain-ai/langchain@langchain-openai==1.7.2...langchain-openai==1.7.4) Updates `langchain-anthropic` from 1.7.6 to 1.7.10 - [Release notes](https://github.com/langchain-ai/langchain/releases) - [Commits](langchain-ai/langchain@langchain-anthropic==1.7.6...langchain-anthropic==1.7.10) Updates `google-genai` from 2.32.0 to 2.33.0 - [Release notes](https://github.com/googleapis/python-genai/releases) - [Changelog](https://github.com/googleapis/python-genai/blob/main/CHANGELOG.md) - [Commits](googleapis/python-genai@v2.32.0...v2.33.0) Updates `langchain-protocol` from 0.0.20 to 0.0.21 - [Release notes](https://github.com/langchain-ai/agent-protocol/releases) - [Commits](langchain-ai/agent-protocol@langchain-protocol==0.0.20...langchain-protocol==0.0.21) Updates `openai` from 2.54.0 to 3.46.0 - [Release notes](https://github.com/openai/openai-python/releases) - [Changelog](https://github.com/openai/openai-python/blob/main/CHANGELOG.md) - [Commits](openai/openai-python@v2.54.0...v3.46.0) --- updated-dependencies: - dependency-name: langchain dependency-version: 1.4.9 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ai-providers - dependency-name: anthropic dependency-version: 2.6.0 dependency-type: direct:production update-type: version-update:semver-major dependency-group: ai-providers - dependency-name: langgraph dependency-version: 1.2.20 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ai-providers - dependency-name: langchain-core dependency-version: 1.7.6 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ai-providers - dependency-name: langchain-openai dependency-version: 1.7.4 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ai-providers - dependency-name: langchain-anthropic dependency-version: 1.7.10 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: ai-providers - dependency-name: google-genai dependency-version: 2.33.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: ai-providers - dependency-name: langchain-protocol dependency-version: 0.0.21 dependency-type: indirect update-type: version-update:semver-patch dependency-group: ai-providers - dependency-name: openai dependency-version: 3.46.0 dependency-type: indirect update-type: version-update:semver-major dependency-group: ai-providers ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* docs: add docstrings to ExceptionCapture public methods Add class-level docstring and per-method docstrings to ExceptionCapture, covering __init__, close, exception_handler, thread_exception_handler, exception_receiver, and capture_exception. No behaviour changes — documentation only. Signed-off-by: mi-vault <asmisharma2026@gmail.com> * docs: clarify bucket_size capacity and exception_receiver caller scope Signed-off-by: mi-vault <asmisharma2026@gmail.com> --------- Signed-off-by: mi-vault <asmisharma2026@gmail.com>
Brings main 83eee80 into v1 so the release-day merge of v1 into main is conflict-free. #1242 (refactor, no behavior change) is left out where v1 rewrote the same code: client.py, async_client.py, consumer.py, _async_consumer.py, _async_request.py, capture_send.py (main's capture_v1.py), ai/prompts.py, ai/utils.py, ai/langchain/callbacks.py, ai/openai_agents/processor.py, ai/claude_agent_sdk/processor.py and the MCP __init__/_instrumentation modules. It merges as is everywhere else. Behavior changes ported onto v1's code in those files: - #1238 failed flag records: EVALUATION_FAILED error, value_from_details for failed records, failed records stay in unresolved_flags. - #1253 Anthropic stream error status (ai/utils.py, langchain). - #1256 Claude Agent SDK tool results, every output block, subagent messages and retried requests. - #1226, #1229, #1231 MCP raised-error reporting and $mcp_error_status (applied from main before #1242). - test_utils.py (#1230), test_pipeline.py (#1226) and test_http_status.py (#1253): both sides kept. main's new tests adapted to v1's contract: - AI events go through capture_ai (#1249 Anthropic stream tests, claude_agent_sdk/test_client.py). - Person processing is the process_person_profile option, not the $process_person_profile property (claude_agent_sdk/test_client.py). - Snapshot flag properties reach _enqueue as flag_properties (test_failed_flag_records.py). Kept from v1: harness 1.26.0 in sdk-compliance.yml, the compliance docker-compose and CONTRIBUTING (HARNESS-1; main moved to 1.31.1). references/public_api_snapshot.txt regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings main f225118 (ExceptionCapture docstrings) into v1. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR overviewNo security issues were found in this pull request. Reviews
|
SDK performance: posthog-python22 changes worth reviewing: 4 observed improvements, 18 observed regressions. Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.
Showing the 12 largest flagged changes; 10 more are in all results. View all results
Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals. Each shard uses its own runner; compare Before PR against With PR within a row, not across shards. Compared 102 metric rows; 102 rows shown in all results. Omitted or shortened data remain in |
dustinbyrne
left a comment
There was a problem hiding this comment.
Review of the merged snapshot 018d15de54954282867f1e3ea65313a282c96419: initial Anthropic stream-request failures discard explicit per-call capture options, allowing global processing settings to win. Both sync and async cases reproduced through the public wrappers and actual SDK transport. Consider forwarding those options in both error handlers and adding the regression in a follow-up.
AI-assisted review.
| time.time() - start_time, | ||
| accumulator.content_blocks, | ||
| accumulator.accumulated_content, | ||
| error=exc, |
There was a problem hiding this comment.
F1 — [P1] Preserve per-call options when the initial Anthropic stream request fails
IMPORTANT · REQUIRED · Introduced event path
Location: posthog/ai/anthropic/anthropic.py:171, with the same omission in anthropic_async.py:171.
When entering messages.stream() fails before iteration—for example, with an initial 401—the new error-capture path emits $ai_generation without the caller’s posthog_options. With an explicit identity and permissive global defaults, that changes requested cookieless/personless processing back to the global settings. The expected result is an error event retaining the same per-call controls as a successful stream.
A supported caller can trigger this with:
with provider.messages.stream(
model=model,
max_tokens=8,
messages=[{"role": "user", "content": "Hello"}],
posthog_distinct_id="user",
posthog_options={
"cookieless_mode": True,
"process_person_profile": False,
},
):
...Both new _capture_streaming_event(..., error=exc) calls omit options=posthog_options; the adjacent successful paths forward it. Public stream() documentation and .sampo/changesets/ai-posthog-options.md promise that these per-call options win over context and super_options. The backend recognizes both controls in rust/capture/src/v1/analytics/types.rs:102–110 at the pinned backend revision.
Executed through both public sync/async wrappers and real SDK HTTP delivery:
| Scenario | Base | Reviewed head |
|---|---|---|
| Initial synthetic 401 | No event | One error event uses process_person_profile: true, cookieless_mode: false from conflicting globals |
| Normal stream / mid-stream SSE error | Requested options retained | Requested options retained |
The base’s missing error event is the intended fix—not evidence that the base captured correctly. The regression is that this newly emitted event bypasses existing per-call restrictions. Content privacy_mode itself is not shown to fail, and real backend person creation was not executed. Bedrock/Vertex reuse these wrapped classes by source inspection; execution covered direct Anthropic wrappers. The similar create(stream=True) omission predates this diff and is not counted separately.
Consider passing options=posthog_options in both new exception handlers, retaining the telemetry guard and original exception re-raise, and adding this regression:
from unittest.mock import AsyncMock, Mock
import pytest
from posthog.ai.anthropic import Anthropic, AsyncAnthropic
@pytest.mark.asyncio
@pytest.mark.parametrize("asynchronous", [False, True])
async def test_initial_request_error_preserves_options(asynchronous):
ph = Mock(privacy_mode=False, enable_full_ai_capture=False)
options = {"cookieless_mode": True, "process_person_profile": False}
failure = RuntimeError("synthetic connect failure")
wrapper = AsyncAnthropic if asynchronous else Anthropic
client = wrapper(api_key="synthetic-key", posthog_client=ph)
client.post = (
AsyncMock(side_effect=failure)
if asynchronous else Mock(side_effect=failure)
)
try:
manager = client.messages.stream(
model="claude-synthetic", max_tokens=1,
messages=[{"role": "user", "content": "synthetic prompt"}],
posthog_distinct_id="synthetic-user", posthog_options=options,
)
with pytest.raises(RuntimeError) as caught:
if asynchronous:
async with manager:
pass
else:
with manager:
pass
assert caught.value is failure
ph.capture_ai.assert_called_once()
assert ph.capture_ai.call_args.kwargs.get("options", {}) == options
finally:
if asynchronous:
await client.close()
else:
client.close()Both cases were executed and fail on the last assertion: {} instead of the requested options. Original exception identity and exactly one capture pass first. The separate transport regression returns base exit 0/head exit 1 specifically for initial-error option precedence. Environment: CPython 3.11.13, pytest 8.4.1, Anthropic 0.120.0 and HTTPX 0.28.1. No fix was applied or tested.
💡 Motivation and Context
v1is missingmain's 7.87.2-7.91.2 and later fixes. These include:The 8.0 release PR (#1016) conflicts with
mainuntilv1carries them.Warning
Do not squash or merge this PR with the button. After approval it lands by fast-forwarding
v1to this exact head, which keeps both merge commits. Squashing drops them, and #1016 keeps conflicting.Changes:
dd8ad56cmergesmain(83eee808). The commit message lists each resolution.v1rewrote the same code: the clients, consumers,capture_send.py, the AI integrations and the MCP instrumentation. It merges as is everywhere else.v1's code in those files:evaluation_failedand stay unresolved.main's new tests are adapted to 8.0's contract: AI events go throughcapture_ai, and person processing is theprocess_person_profileoption._enqueueasflag_properties.mainmoved to 1.31.1.c8ab322dregeneratesreferences/posthog-python-8.mdwithmain's new API.018d15demerges docs: add docstrings to ExceptionCapture public methods #1257 (docstrings).💚 How did you test it?
mainadded or removed since the last sync, outside refactor: reduce SDK complexity and improve CRAP analysis #1242, is on this head, except the listed adaptations.v1line is kept, except one comment rewrapped to adderror_status.main's tests for each ported fix. The 3 fork tests intest_metrics_autocapture.pyfail locally on pristinev1too (macOS fork).utils.pyCRAP gate pass.mainhas 0 conflicts, and the result equals this head.📝 Checklist
If releasing new changes
sampo addto generate a changeset fileNo changeset:
main's changes shipped in 7.87.2-7.91.2, and 8.0's changesets are onv1.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code (Claude Opus 5.5).
🤖 Generated with Claude Code