fix(langgraph): use identity check for Command.update in map_command#7087
Open
Giulio Leone (giulio-leone) wants to merge 1 commit intolangchain-ai:mainfrom
Open
fix(langgraph): use identity check for Command.update in map_command#7087Giulio Leone (giulio-leone) wants to merge 1 commit intolangchain-ai:mainfrom
Giulio Leone (giulio-leone) wants to merge 1 commit intolangchain-ai:mainfrom
Conversation
Author
✅ Verified with real graph executionEnvironment: Python 3.13.12, macOS, Bug proof — old behavior silently drops falsy updates:from langgraph.types import Command
def old_check(cmd): return bool(cmd.update) # old: truthy
def new_check(cmd): return cmd.update is not None # new: identity
for val in [0, False, "", {"key": "val"}]:
cmd = Command(update=val)
print(f"Command(update={val!r}): old={old_check(cmd)}, new={new_check(cmd)}")Fix verified — real graph with
|
Author
|
William FH (@hinthornw) Found this during a source audit — |
map_command() used a truthy check (`if cmd.update:`) instead of an identity check (`if cmd.update is not None:`) for the update field. This silently drops falsy but valid state updates like Command(update=0), Command(update=False), or Command(update=''). The adjacent resume field already uses the correct pattern (`if cmd.resume is not None:`), and _update_as_tuples() also uses `is not None`. This aligns map_command with the rest of the codebase.
481b53f to
4e7a7f8
Compare
Author
|
Friendly ping — this branch has been refreshed on the latest upstream base and all current review feedback has been addressed. It should be ready for review whenever you have a chance. Happy to make any further changes quickly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
map_command()in_io.pyuses a truthy check (if cmd.update:) instead of an identity check (if cmd.update is not None:) for theupdatefield. This silently drops falsy but valid state updates:The adjacent
resumefield already uses the correct pattern:And
_update_as_tuples()also correctly usesself.update is not None.Fix
Changed
if cmd.update:toif cmd.update is not None:to align with the rest of the codebase.Tests
Added
test_map_command.pywith 10 tests verifying that:0,False,"") are correctly propagated throughmap_commandNonesentinel correctly produces no writes