Skip to content

Fix prompt validation: declare lm_top_k/repainting_start/repainting_end as STRING to survive stale empty-string widget values#12

Merged
lmangani merged 2 commits into
mainfrom
copilot/fix-prompt-validation-issues
Mar 14, 2026
Merged

Fix prompt validation: declare lm_top_k/repainting_start/repainting_end as STRING to survive stale empty-string widget values#12
lmangani merged 2 commits into
mainfrom
copilot/fix-prompt-validation-issues

Conversation

Copilot AI commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

PR #11's VALIDATE_INPUTS fix was based on a wrong assumption. ComfyUI's execution.py runs int(val) / float(val) unconditionally in an else branch (lines 901–936) before VALIDATE_INPUTS is ever called — so listing fields there bypasses only range (min/max) checking, not type coercion. int('') and float('') still raise, errors are recorded, and the prompt fails even when VALIDATE_INPUTS returns True.

Fix

Declare lm_top_k, repainting_start, and repainting_end as STRING instead of INT/FLOAT in INPUT_TYPES. ComfyUI then runs str('') (always succeeds). The existing _coerce_int / _coerce_float helpers in generate() convert empty strings to numeric defaults at runtime.

# Before — ComfyUI runs int('') / float('') → ValueError before generate() is reached
"lm_top_k":       ("INT",   {"default": 0,    "min": 0, "max": 1000}),
"repainting_start": ("FLOAT", {"default": -1.0, "min": -1.0, "max": 600.0}),
"repainting_end":   ("FLOAT", {"default": -1.0, "min": -1.0, "max": 600.0}),

# After — ComfyUI runs str('') → '' → _coerce_int/float handles it
"lm_top_k":       ("STRING", {"default": "0"}),
"repainting_start": ("STRING", {"default": "-1.0"}),
"repainting_end":   ("STRING", {"default": "-1.0"}),

Files changed

  • nodes.py — Change the three fields to STRING; update generate() signatures to Union[str, int] / Union[str, float]; correct VALIDATE_INPUTS docstring (it does not bypass type coercion).
  • workflow-examples/*.json (all 4) — Widget positions 15, 19, 20 updated from JSON numbers to JSON strings ("0", "-1.0") to match the new type declarations.
  • tests/test_nodes.py — Three new tests assert STRING type for the changed fields; updated TestValidateInputs docstring.
  • tests/test_workflows.py — Workflow tests for positions 15/19/20 now check parseability (int(str(val)) / float(str(val))) instead of isinstance(…, int/float).

💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

…d to STRING type; update workflow examples

Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix prompt validation failures for output 3 Fix prompt validation: declare lm_top_k/repainting_start/repainting_end as STRING to survive stale empty-string widget values Mar 14, 2026
Copilot AI requested a review from lmangani March 14, 2026 15:06
@lmangani lmangani marked this pull request as ready for review March 14, 2026 15:28
@lmangani lmangani merged commit a5a6987 into main Mar 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants