fix(frontend): block invalid step names instead of only warning - #934
fix(frontend): block invalid step names instead of only warning#934Bhavd33p wants to merge 1 commit into
Conversation
Input.tsx let handleChange call updateValue() regardless of the computed regex/maxLength/onBeforeUpdate error, so a step name like add-strings was saved into the notebook (and could be wired up as a dependency) even though it fails validation, only to break pipeline compilation later since step names are spliced into the generated code as Python identifiers. Track the field's live text in local component state, separate from the committed value, so invalid input still renders with the error styling but is never propagated to the notebook via updateValue. Also reword STEP_NAME_ERROR_MSG to explain why hyphens are allowed in pipeline names but not step names. Fixes kubeflow#882 Signed-off-by: [Bhavdeep Singh] <bhavdeep3singh@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Read through this one — the fix looks right to me, and the local-state split is the correct shape: the field keeps showing the invalid text (with the error styling) while never letting it reach Since
The Nice touch reworking Non-binding LGTM (not a maintainer). |
Summary
Input.tsx'shandleChangecalledupdateValue()unconditionally, regardless of whether the typed value failed the regex/maxLength/onBeforeUpdatevalidation. For the pipeline-step-name field this meant a name likeadd-stringsgot saved into the notebook cell metadata (and could be selected as a dependency by other steps) even though it's invalid — it would only fail later, at pipeline compile time, with a confusing error, since step names are spliced into the generated code as Python function/variable identifiers (so hyphens can't be allowed there, unlike pipeline names which follow DNS-1123 naming and do allow hyphens).Inputnow tracks the field's live text in local state, separate from the committed value passed viaupdateValue. Invalid text still renders in the field with the existing red error styling/message (so users can see and fix it), but it's never propagated toupdateValue/notebook metadata. This also incidentally fixes the same class of bug for duplicate step names (theonBeforeUpdatecheck), which had the identical problem.STEP_NAME_ERROR_MSGto explain why hyphens aren't allowed for step names (unlike pipeline names), instead of just stating the rule.Fixes #882
Test plan
tsc --noEmit,eslint:check,prettier:checkall pass.jestpasses (no labextension component tests exist yet in this repo to extend).add-strings) now shows the reworded error message live and is never committed (no tag chip appears above the cell, confirmed against the notebook's actual cell metadata). Fixing it to a valid name (e.g.add_strings) commits normally and shows the step chip.