Compare commits

...
Author SHA1 Message Date
William FHandGitHub 8f62374658 release(cli): 0.4.18 (#7186) 2026-03-15 16:53:39 -07:00
William FHandGitHub bec531980d chore: update error message (#7185) 2026-03-15 16:46:15 -07:00
60385e452f fix(checkpoint): don't add the task to the checkpoint batch if it was… (#7168)
Cleaning up CI for #6701 
```md
  I'm trying to help a customer with some issues related to their checkpointing in postgres. They have some timeouts and retries around the langgraph checkpoint queries and I suspect the queue may be filling up with cancelled tasks.
  
  This PR adds some eager checks to not execute an operation if the future was already cancelled.
  This is to prevent the queue executing tasks that might have already timed out, which would otherwise cause more tasks to timeout due to the longer execution delay.
  
  Thank you for contributing to LangGraph! Follow these steps to mark your pull request as ready for review. **If any of these steps are not completed, your PR will not be considered for review.**
```

Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
2026-03-15 12:46:27 -07:00
4 changed files with 136 additions and 18 deletions
@@ -328,6 +328,9 @@ async def _run(
store: weakref.ReferenceType[BaseStore],
) -> None:
while item := await aqueue.get():
# don't run batch if the future is done (e.g. cancelled)
if item[0].done():
continue
# check if store is still alive
if s := store():
try:
@@ -335,6 +338,9 @@ async def _run(
items = [item]
try:
while item := aqueue.get_nowait():
# don't insert if the future is done (e.g. cancelled)
if item[0].done():
continue
items.append(item)
except asyncio.QueueEmpty:
pass
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.4.17"
__version__ = "0.4.18"
+37 -17
View File
@@ -764,7 +764,7 @@ def _deploy_base_options(
@cli.group(
cls=DeployGroup,
help=(
"[Beta] Build and deploy a LangGraph image to LangSmith Deployments.\n\n"
"[Beta] Build and deploy a LangGraph image to LangSmith Deployment.\n\n"
"This command is in beta and under active development. "
"Expect frequent updates and improvements.\n\n"
"Run from the root of your LangGraph project (where langgraph.json "
@@ -1122,7 +1122,7 @@ def _deploy(
)
else:
click.secho(
" Check status in the LangSmith Deployments dashboard.",
" Check status in the LangSmith Deployment dashboard.",
fg="yellow",
)
@@ -1165,22 +1165,42 @@ def _call_host_backend_with_optional_tenant(
in-place so all subsequent calls through the same instance are
tenant-aware.
"""
try:
return operation(client)
except HostBackendError as err:
if err.status_code == 403 and "requires workspace specification" in err.message:
click.secho(
"Your API key is org-scoped and requires a workspace ID.",
fg="yellow",
)
click.secho(
"Find your workspace ID in LangSmith under Settings > Workspaces.",
fg="yellow",
)
tenant_id = click.prompt("Workspace ID")
client._client.headers["X-Tenant-ID"] = tenant_id
prompted_for_tenant = False
while True:
try:
return operation(client)
raise
except HostBackendError as err:
if (
not prompted_for_tenant
and err.status_code == 403
and "requires workspace specification" in err.message
):
click.secho(
"Your API key is org-scoped and requires a workspace ID.",
fg="yellow",
)
click.secho(
"Find your workspace ID in LangSmith under Settings > Workspaces.",
fg="yellow",
)
client._client.headers["X-Tenant-ID"] = click.prompt("Workspace ID")
prompted_for_tenant = True
continue
if err.status_code == 403 and "not enabled" in err.message.lower():
from urllib.parse import urlparse
smith_host = "smith.langchain.com"
parsed = urlparse(client._base_url)
if (parsed.hostname or "").startswith("eu."):
smith_host = "eu.smith.langchain.com"
raise HostBackendError(
"LangSmith Deployment is not enabled for this organization. "
f"Enable it at https://{smith_host}/host/deployments"
" (ensure this matches the organization for your API key).",
status_code=403,
) from None
raise
@OPT_HOST_API_KEY
@@ -3,14 +3,17 @@ import json
import os
import click
import httpx
import pytest
from langgraph_cli.cli import (
_call_host_backend_with_optional_tenant,
_docker_config_for_token,
_normalize_image_name,
_normalize_image_tag,
_parse_env_from_config,
)
from langgraph_cli.host_backend import HostBackendClient, HostBackendError
class TestDockerConfigForToken:
@@ -132,3 +135,92 @@ class TestParseEnvFromConfig:
assert result["GOOD"] == "value"
# EMPTY= gives empty string, not None, so it should be present
assert result["EMPTY"] == ""
class TestCallHostBackendWithOptionalTenant:
def _make_client(self, handler):
c = HostBackendClient("https://api.example.com", "test-key")
c._client = httpx.Client(
base_url="https://api.example.com",
transport=httpx.MockTransport(handler),
headers={"X-Api-Key": "test-key", "Accept": "application/json"},
timeout=30,
)
return c
def _make_eu_client(self, handler):
c = HostBackendClient("https://eu.api.host.langchain.com", "test-key")
c._client = httpx.Client(
base_url="https://eu.api.host.langchain.com",
transport=httpx.MockTransport(handler),
headers={"X-Api-Key": "test-key", "Accept": "application/json"},
timeout=30,
)
return c
def test_success_passes_through(self):
client = self._make_client(lambda req: httpx.Response(200, json={"ok": True}))
result = _call_host_backend_with_optional_tenant(
client, lambda c: c.list_deployments()
)
assert result == {"ok": True}
def test_403_not_enabled_gives_actionable_error(self):
detail = (
'{"detail":"LangSmith Deployment is not enabled for this organization"}'
)
client = self._make_client(lambda req: httpx.Response(403, text=detail))
with pytest.raises(HostBackendError, match="not enabled") as exc_info:
_call_host_backend_with_optional_tenant(
client, lambda c: c.list_deployments()
)
assert exc_info.value.status_code == 403
assert "smith.langchain.com" in exc_info.value.message
def test_403_not_enabled_eu_url(self):
detail = (
'{"detail":"LangSmith Deployment is not enabled for this organization"}'
)
client = self._make_eu_client(lambda req: httpx.Response(403, text=detail))
with pytest.raises(HostBackendError, match="not enabled") as exc_info:
_call_host_backend_with_optional_tenant(
client, lambda c: c.list_deployments()
)
assert "eu.smith.langchain.com" in exc_info.value.message
def test_workspace_retry_then_not_enabled_gives_actionable_error(self, monkeypatch):
requires_workspace = '{"detail":"requires workspace specification"}'
not_enabled = (
'{"detail":"LangSmith Deployment is not enabled for this organization"}'
)
seen_tenant_ids = []
def handler(req):
seen_tenant_ids.append(req.headers.get("X-Tenant-ID"))
if len(seen_tenant_ids) == 1:
return httpx.Response(403, text=requires_workspace)
if len(seen_tenant_ids) == 2:
return httpx.Response(403, text=not_enabled)
raise AssertionError("unexpected extra request")
monkeypatch.setattr(click, "prompt", lambda _text: "workspace-123")
client = self._make_client(handler)
with pytest.raises(HostBackendError, match="not enabled") as exc_info:
_call_host_backend_with_optional_tenant(
client, lambda c: c.list_deployments()
)
assert exc_info.value.status_code == 403
assert "smith.langchain.com" in exc_info.value.message
assert seen_tenant_ids == [None, "workspace-123"]
assert client._client.headers["X-Tenant-ID"] == "workspace-123"
def test_other_403_re_raises_original(self):
client = self._make_client(
lambda req: httpx.Response(403, text='{"detail":"some other error"}')
)
with pytest.raises(HostBackendError, match="some other error"):
_call_host_backend_with_optional_tenant(
client, lambda c: c.list_deployments()
)