Pass the schema default for optional inputs a prompt leaves out - #15740
Pass the schema default for optional inputs a prompt leaves out#15740christian-byrne wants to merge 3 commits into
Conversation
An API-format prompt saved before an optional input existed does not carry it, and get_input_data only passes the keys the prompt has, so the node is called without the argument and raises TypeError. 75 optional inputs in core are in that state today. Only fill in inputs whose function parameter has no default of its own, so nodes that use a sentinel default, like SoftSwitchNode, still see the input as missing.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 4 minutes Limit details: You’ve used all 2 included reviews currently available. Your 80 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?Wait for the limit to reset, then comment An organization admin can change what happens after included review limits in Billing. How do review limits work?CodeRabbit enforces per-developer PR review limits within each organization. For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Comment |
|
@coderabbitai review |
|
An API-format prompt saved before an optional input was added does not carry it, and
get_input_dataonly passes the keys the prompt has, so the node is called without the argument and raises TypeError.INPUT_TYPESdefaults are never injected, so the value has to come from a default in the entry function, and 75 optional inputs in core do not have one. This fills those from the schema default, which makes "optional with a default" mean the input simply does not have to be provided. It only applies where the parameter has no default of its own, so a node using a sentinel to detect a missing input, likeSoftSwitchNodewithMISSING, still sees it missing — and a node whose schema default disagrees with its signature default keeps using the signature. Optional inputs with no schema default are untouched; those are nullable values, and the sibling PR #15739 lints that their parameter carries a default.Reproduced against a running server with a real API-format prompt.
TestOmittedOptionalInput.scaleis optional with{"default": 0.5}in the schema and no default inprocess(), and the prompt omits it:{"prompt": { "1": {"class_type": "StubImage", "inputs": {"content": "WHITE", "height": 64, "width": 64, "batch_size": 1}}, "2": {"class_type": "TestOmittedOptionalInput", "inputs": {"image": ["1", 0]}}, "3": {"class_type": "SaveImage", "inputs": {"images": ["2", 0], "filename_prefix": "e2e"}} }}Before, validation accepts it and execution dies:
After, it runs and the default arrives — a white image scaled by 0.5 is 127:
Tests
tests/execution/test_omitted_optional_input.pycovers that over HTTP: the omitted input gets its schema default, a provided value still wins, and a connected nullable socket is still delivered. Reverting only theexecution.pyhunk fails 2 of the 3.tests-unit/execution_test/omitted_optional_input_test.pyadds the unit-level cases, including that a V3 node resolves throughexecuterather than theEXECUTE_NORMALIZEDtrampoline.