Skip to content

Let update_session clear the key and make project_id optional for single sessions - #206

Merged
Mo-Elshenawy1 merged 3 commits into
mainfrom
claude/exciting-cori-o7rsiy-sessions
Nov 6, 2026
Merged

Mo-Elshenawy1 merged 3 commits into
mainfrom
claude/exciting-cori-o7rsiy-sessions

Conversation

@Mo-Elshenawy1

@Mo-Elshenawy1 Mo-Elshenawy1 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Changelog

update_session can now clear a session's key with new_key=None, and project_id is optional for get_session, update_session and delete_session.

Docs

None

Description

The v1 API treats key on PATCH /sessions/{keyOrId} as nullable, where null clears it. It also makes projectId optional on the single-session endpoints; it's needed only in multi-project organizations. The client couldn't clear a key, because new_key=None meant "omit", and it required project_id.

  • update_session now uses the client's existing _UNSET pattern: leaving out new_key keeps the key, a string sets it, and None clears it.
  • project_id is optional on get_session, update_session and delete_session, and is sent only when given.
  • The session properties type hints accept lists of strings for multi-value properties. On update_session they also accept None, which unsets that property, as the docstring now says. Both already worked at runtime.

Compatibility: code that passed new_key=None explicitly used to leave the key unchanged and will now clear it. Callers that leave it out or pass a string see no change.

Validated with black, flake8, pyright, and pytest on Python 3.8: 206 passed, including the new tests in tests/test_sessions.py. The ROS message tests can't install their dependencies in my environment, so CI covers those.

BeforeAfter

client.update_session(session_id="ses_1", project_id="prj_1", new_key=None) left the key unchanged, and client.get_session(session_id="ses_1") raised TypeError for the missing project_id.

The update sends {"key": null} and clears the key. client.get_session(session_id="ses_1") sends no projectId.

🤖 Generated with Claude Code

https://claude.ai/code/session_012yf4xszPJuZbmsVHpZeUGr

`update_session(new_key=None)` now clears the session's key; omitting
`new_key` leaves it unchanged. `project_id` is now optional for
`get_session`, `update_session`, and `delete_session` and is only sent
when provided, since it is required only for multi-project
organizations. The `update_session` docstring notes that a property
value of `None` unsets that property.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yf4xszPJuZbmsVHpZeUGr
@linear-code

linear-code Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

BFCK-400

DC-2076

@foxglove-beefcake foxglove-beefcake Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Risk: high. The public SDK behavior changes so that an explicit new_key=None now clears the stored session key, and a revert does not restore keys that callers cleared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012yf4xszPJuZbmsVHpZeUGr

@foxglove-beefcake foxglove-beefcake Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Risk: high. The public SDK behavior changes so that an explicit new_key=None now clears the stored session key, and a revert does not restore keys that callers cleared.

@foxglove-beefcake foxglove-beefcake Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Risk: high. The public SDK behavior changes so that an explicit new_key=None now clears the stored session key, and a revert does not restore keys that callers cleared.

@Mo-Elshenawy1
Mo-Elshenawy1 merged commit 1c87ed6 into main Nov 6, 2026
2 checks passed
@Mo-Elshenawy1
Mo-Elshenawy1 deleted the claude/exciting-cori-o7rsiy-sessions branch November 6, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants