-
Notifications
You must be signed in to change notification settings - Fork 667
CONSOLE-4880: Bump 'yup' version #15737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@krishagarwal278: This pull request references CONSOLE-4880 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughYup dependencies were upgraded and many Yup validation schemas across frontend packages were refactored to use functional then-callbacks, schema.concat(), and .shape(); multiple top-level validation test callbacks were made async; two devconsole locale entries were removed; some tests and mock data were updated. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Comment |
|
@krishagarwal278: This pull request references CONSOLE-4880 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
1 similar comment
|
@krishagarwal278: This pull request references CONSOLE-4880 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@krishagarwal278: This pull request references CONSOLE-4880 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts (1)
10-25: Test mock data structure does not match validation schema; "optionality" error type does not existThe validation schema expects nested
subject { name, kind }but the test mock data provides a flatuserfield. The schema has no custom test named"optionality"—all three fields (subject.name,subject.kind,role) use only.required(), which produces error type"required", not"optionality".Test 1 modifies a field (
user) that the schema doesn't validate and expects an error type that doesn't exist in the schema definition. Test 2 correctly matches the schema structure. The mock data and/or schema definitions need to be aligned.
🧹 Nitpick comments (7)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.ts (1)
107-107: Consider using Partial for type safety.The mock error objects use type assertions to bypass TypeScript checking. While this works for tests that only consume the
innerproperty, consider usingPartial<ValidationError>or a mock factory to improve type safety and test maintainability.Example refactor:
- const error = { inner: [{ path: 'spec.tasks[0].name' }] } as ValidationError; + const error = { inner: [{ path: 'spec.tasks[0].name' }] } as Partial<ValidationError>;Also applies to: 123-123, 141-141, 164-164
frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts (1)
10-23: Yupwhen(...).thencallback usage is correct; consider addressing the Biome false positiveUsing
then: (schema) => schema.shape({ project, application, name })here is the right pattern for Yup 1.x: it preserves any existing constraints onformDatawhile adding the broker‑specific fields. The BiomenoThenPropertywarning is a generic rule about thenables and doesn’t apply to Yup’swhenconfiguration object, so you may want to suppress this rule for these cases (via config or a targeted// biome-ignore lint/suspicious/noThenPropertycomment) to keep lint noise down.frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
16-67: Yup 1.xwhen/thenmigration looks correct; BiomenoThenPropertyis a false positiveThe switch to
then: (schema) => schema.shape({...})fordata,httpGet,tcpSocket, andexecis the right additive pattern for Yup 1.x and keeps the existing shape/constraints intact whenshowForm/requestTypematch.Biome’s
lint/suspicious/noThenPropertyerrors on these lines are false positives for Yup’s.when()options object. Consider either:
- Adding a local ignore (for example,
// biome-ignore lint/suspicious/noThenPropertyimmediately above eachwhen({ is, then: ... })), or- Relaxing this rule in your Biome config for Yup schemas,
so the linter doesn’t keep flagging valid uses of
thenhere.frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
22-35: Yup conditional schemas are correctly migrated; consider taming Biome’snoThenPropertylintThe refactor to use functional
thencallbacks (then: (schema) => schema.shape(...)/schema.concat(...)) acrosssinkServiceSchema,sourceDataSpecSchema,eventSourceValidationSchema, andaddChannelValidationSchemais consistent with Yup 1.x best practices and keeps the existing validation behavior, while making the conditions additive instead of replacing base schemas.Biome’s
lint/suspicious/noThenPropertyerrors on thesewhen({ is, then })objects are expected with Yup and not an actual bug. It’s worth either:
- Adding targeted ignores around these
whenblocks, or- Adjusting Biome configuration so Yup
.when()options are exempt from this rule,to avoid linter noise on perfectly valid schema definitions.
Also applies to: 37-160, 162-177, 179-194
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
48-49: Yupwhen/thenrefactors look good; BiomenoThenPropertyremains a lint/config issueAcross
applicationNameValidationSchema,serverlessValidationSchema,routeValidationSchema,imageValidationSchema,gitValidationSchema,dockerValidationSchema,devfileValidationSchema,isiValidationSchema, andimportFlowPipelineTemplateValidationSchema, the migration tothen: (schema) => schema.shape(...)orthen: (schema) => schema.required(...)correctly follows Yup 1.x’s additive pattern and should preserve existing validation behavior.The Biome
lint/suspicious/noThenPropertyerrors on these lines stem from the linter not recognizing Yup’s.when()options signature. You don’t need to change the schema logic; instead, consider either adding localized ignores around thesewhenobjects or updating Biome config so Yup’sthen/otherwisecallbacks aren’t flagged.Also applies to: 80-181, 183-192, 298-307, 309-324, 325-335, 337-351, 359-367, 369-379
214-295: Guard cross-field limit/request tests to avoid convertingundefinedvaluesThe new
.nullable()handling and explicitlimit !== undefined && limit !== nullchecks inlimitsValidationSchemaimprove robustness when limits are left blank.One remaining edge case: in the CPU and memory tests you still call
convertToBaseValue(\${request}${requestUnit}`)(or the symmetric expression) even whenrequestisundefinedbutlimitis set. Depending on howconvertToBaseValuebehaves, that can lead toNaN` comparisons or surprising validation failures when the user leaves one side empty.Consider tightening the guards in both CPU and memory tests, e.g.:
- Only run the comparison when both
requestandlimitare notundefined/null, or- Early-return
truewhen the side being read (requestin the limit test,limitin the request test) isundefined/null.That keeps the cross-field constraints focused on cases where both values are actually present.
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx (1)
78-85: Correct use ofschema.concatfor URI validation; Biome lint is non-blockingSwitching the
sinkwhenbranch to:then: (schema) => schema.concat(sinkTypeUriValidation(t)),is a good improvement — it augments the existing
sinkschema with URI-specific rules without discarding other fields onsink.Biome’s
lint/suspicious/noThenPropertyon thiswhenblock is just the linter disliking athenproperty on plain objects; it’s required by Yup’s API. You can safely keep this code and address the lint via a local ignore or Biome config change.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
⛔ Files ignored due to path filters (1)
frontend/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (22)
frontend/package.json(1 hunks)frontend/packages/dev-console/locales/en/devconsole.json(0 hunks)frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts(3 hunks)frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/hpa/validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/validation-schema.ts(10 hunks)frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts(1 hunks)frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts(2 hunks)frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx(1 hunks)frontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx(1 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts(3 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.ts(5 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts(3 hunks)frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts(2 hunks)frontend/packages/shipwright-plugin/src/components/build-form/validation.ts(1 hunks)frontend/packages/vsphere-plugin/package.json(1 hunks)frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts(1 hunks)frontend/public/components/configmaps/configmap-utils.ts(1 hunks)
💤 Files with no reviewable changes (1)
- frontend/packages/dev-console/locales/en/devconsole.json
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.tsfrontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsxfrontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.tsfrontend/packages/vsphere-plugin/package.jsonfrontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.tsfrontend/public/components/configmaps/configmap-utils.tsfrontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.tsfrontend/package.jsonfrontend/packages/dev-console/src/components/hpa/validation-utils.tsfrontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.tsfrontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.tsfrontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.tsfrontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.tsfrontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.tsfrontend/packages/dev-console/src/components/import/validation-schema.tsfrontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.tsfrontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.tsfrontend/packages/dev-console/src/components/buildconfig/form-utils/validation.tsfrontend/packages/shipwright-plugin/src/components/build-form/validation.tsfrontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.tsfrontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx
🪛 Biome (2.1.2)
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts
[error] 23-23: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/public/components/configmaps/configmap-utils.ts
[error] 208-208: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 212-212: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts
[error] 16-16: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 45-45: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 56-56: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 63-63: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/hpa/validation-utils.ts
[error] 12-12: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts
[error] 15-15: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts
[error] 14-14: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 22-22: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 29-29: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 38-38: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 49-49: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 74-74: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 89-89: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 104-104: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 113-113: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts
[error] 27-27: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 34-34: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 42-42: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 55-55: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 97-97: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 146-146: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 167-167: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 184-184: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts
[error] 18-18: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 25-25: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 33-33: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 50-50: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 58-58: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 125-125: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 140-140: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/import/validation-schema.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 188-188: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 301-301: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 317-317: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 328-328: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 340-340: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 375-375: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts
[error] 41-41: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts
[error] 485-485: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts
[error] 17-17: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 28-28: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 38-38: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 49-49: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 53-53: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 95-95: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 99-99: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/shipwright-plugin/src/components/build-form/validation.ts
[error] 54-54: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 58-58: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 100-100: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
🔇 Additional comments (27)
frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts (1)
21-30: LGTM! Yup 1.x conditional migration is correct.The migration from static
thenclause to functional callback pattern is correct for Yup 1.x. The validation logic remains unchanged—when the namespace equalsCREATE_NAMESPACE_KEY, the schema applies the regex match and required validation.Note: The Biome static analysis warning on line 23 (
lint/suspicious/noThenProperty) is a false positive. Thethenproperty is valid in Yup's conditional schema API (yup.when()), and the functional callback patternthen: (schema) => ...is the correct approach for Yup 1.x.frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.ts (1)
2-2: LGTM: ValidationError import added for test typing.The import is correctly added to support type assertions in test mocks.
frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts (1)
35-47: Yup 1.x migration looks correct.The migration correctly implements Yup 1.x patterns:
- Async test function for Promise-based validation
- Functional
thencallback withschema.concat()for conditional schema composition- Explicit
awaitand return for async flowThe Biome lint warning on line 41 is a false positive—
thenis a valid property in Yup's.when()conditional API, not a Promise-like object.frontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx (1)
135-141: LGTM! Type safety improvement.The migration from
Yup.mixed()toYup.string()appropriately tightens the type for the name field, and the added type annotation(value: string)in the test callback improves TypeScript clarity. The unique-name validation logic remains correct, and the schema composition viaconcat()is compatible with Yup 1.x.frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts (5)
7-55: LGTM! Yup 1.x migration correctly applied.The conversion from object-literal
thento function-basedthen: (schema) => schema.shape(...)is correct for Yup 1.x. All conditional validations for git, image, storage, and cluster resource types maintain the same validation requirements.
57-67: LGTM! Schema composition withconcat()correctly implemented.The functional
thenpattern combined withschema.concat(validateResourceType())is the correct Yup 1.x approach for composing validation schemas conditionally.
69-130: LGTM! Volume type validations correctly migrated.All four volume type branches (Secret, ConfigMap, PVC, VolumeClaimTemplate) use the correct Yup 1.x functional
thenpattern. The deeply nested VolumeClaimTemplate schema structure is properly maintained with correct nesting levels.
132-155: LGTM! Common pipeline schema correctly structured.The schema composition is correct, and the synchronous
.test()validation at lines 141-145 is valid for Yup 1.x (no async conversion needed since it returns a boolean without async operations).
1-185: Static analysis warnings are false positives.Biome's
noThenPropertyrule flags allthenproperties in this file, but these are Yup's conditional validation API (when().then()), not Promise thenables. The functional patternthen: (schema) => schema.shape(...)is the correct Yup 1.x syntax.Consider suppressing this Biome rule for validation files using Yup's
when()API:// biome-ignore lint/suspicious/noThenProperty: Yup's conditional validation API uses 'then' propertyOr configure
.biome.jsonto disable this rule for validation utility files:{ "overrides": [ { "include": ["**/*validation*.ts"], "linter": { "rules": { "suspicious": { "noThenProperty": "off" } } } } ] }frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (4)
46-60: LGTM! Correct Yup 1.x conditional schema pattern.The migration from static shape to functional
thencallback is correct for Yup 1.x compatibility. The Biome warning on line 48 is a false positive—thenis a legitimate property in Yup'swhen()API, not a Promise chain.
61-73: LGTM! Conditional validation and synchronous tests are correct.The functional
thencallback is properly implemented. The custom.test()functions don't require async conversion since they perform synchronous checks onthis.parentwithout callingvalidate().
95-109: LGTM! Conditional validation correctly migrated.The functional
thencallback and synchronous test functions are properly implemented for Yup 1.x.
114-117: LGTM! Schema composition using concat is correct.The use of
schema.concat(pipelinesAccessTokenValidationSchema(t))correctly merges the validation schemas rather than replacing them, which preserves any existing validations on therepositoryfield.frontend/packages/dev-console/src/components/hpa/validation-utils.ts (2)
12-12: Biome warning is a false positive; ignore it.The static analysis warning "Do not add then to an object" misinterprets the Yup API. Here,
thenis a valid property in the options object passed toyup.when(), not the Promise method being added to a plain object.
12-56: Fix cross-field validation edge case when minReplicas is undefined.The review comment correctly identifies a potential validation bug. Since
minReplicaslacks.required()whilemaxReplicashas it, whenminReplicasis undefined, the test expressionundefined <= maxReplicasevaluates tofalse, causingmaxReplicasvalidation to fail even when the user legitimately omits the field.The suggested guard clause on line 51 is the correct defensive approach. Either add the guard:
function (maxReplicas) { const { minReplicas } = this.parent; + if (minReplicas == null) return true; return minReplicas <= maxReplicas; }Or, if
minReplicasshould be required in all cases, add.required(t(...))on line 27 to matchmaxReplicas. Without one of these changes, the form cannot be submitted whenminReplicasis left empty—a usability and consistency issue.frontend/packages/vsphere-plugin/package.json (1)
9-13: Yup version bump here is consistent with the root package and looks good
@console/vsphere-pluginnow depends onyup@^1.7.1, which keeps it in sync with the main frontend package and avoids mixed major versions of Yup within the workspace. Just ensure vsphere-plugin validation flows/tests are exercised after the upgrade.frontend/package.json (1)
135-221: Root Yup upgrade is scoped and appropriateBumping the main
openshift-consoledependency toyup@^1.7.1aligns with the schema changes in this PR. The change is isolated to the Yup version, so the main follow‑up is to run the recommended validation‑focused test suites to catch any subtle behavioral differences.frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
44-65: Async Yup test withschema.concatis a sound migration patternThe
async test(values)implementation that builds aformYamlDefinitionschema, awaitsformYamlDefinition.validate(values, { abortEarly: false }), and returnstrueis a solid adaptation for Yup 1.x. Usingthen: (schema) => schema.concat(formDataSchema())/schema.concat(yup.string().required(...))ensures editor‑type‑specific constraints are layered on top of the base schema instead of replacing it. Any validation failures will still propagate via the rejectedvalidatecall.frontend/public/components/configmaps/configmap-utils.ts (1)
191-219: ConfigMap form/YAML validation migration aligns with the new Yup patternThe updated
validationSchemacorrectly switches to anasync test(values)that delegates to aformYamlDefinitionschema and returnstrueon successful validation. Usingwhen('editorType', { then: (schema) => schema.concat(formDataSchema(values)) })and a similar pattern foryamlDatacleanly composes editor‑specific constraints with the base schema while still allowingkeyValueValidation(values)to enforce uniqueness acrossdataandbinaryData.frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (1)
248-305: Resource/workspace checks and async form/YAML validation look correctCoercing
resourceValueandworkspaceValuewith!!in the required tests makes the intent explicit without changing behavior, since these fields are string identifiers. The updatedvalidationSchemathat usesasync test(formValues)pluswhen('editorType', { then: (schema) => schema.concat(pipelineBuilderFormSchema(formValues)) })and awaitsformYamlDefinition.validate(...)is consistent with the other Yup 1.x migrations and should continue to enforce the same structural constraints on pipeline builder forms.Also applies to: 383-395, 477-491
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts (1)
106-130: Deployment edit validation uses the right Yup 1.x composition patternsThe
imageStreamandisibranches now usethen: (schema) => schema.shape({ ... }), which extends the existing object schema instead of replacing it, and the top-levelvalidationSchemawraps the combined Form/YAML validation in anasync test(formValues)that awaitsformYamlDefinition.validate(formValues, { abortEarly: false })and returnstrue. This matches the other updated validators in the PR and keeps the conditionalfromImageStreamTagbehavior intact while aligning with Yup 1.x’s Promise-based API.Also applies to: 132-146
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (2)
33-55: Async top-level test correctly adapts to Yup 1.x; ensure all callers handle the PromiseThe updated
validationSchemanow uses anasync testandawait formYamlDefinition.validate(values, { abortEarly: false }), which is the right way to migrate away fromvalidateSyncin Yup 1.x while preserving aggregated error reporting.Since the test is now asynchronous, callers must treat
validationSchema()as returning a schema whosevalidatemethod yields aPromise. This matches how Formik and your existing validation plumbing typically integrate with Yup, but please confirm there are no call sites expecting purely synchronous validation for this schema.Also applies to: 85-105
15-31: Verify that thedockerfilefield validation is intentionally optionalThe async test pattern is correct for Yup 1.x:
await formYamlDefinition.validate(values, { abortEarly: false })properly handles asynchronous validation and will throw detailed errors as expected.However, the
dockerfilebranch shows an asymmetry worth confirming:dockerfile: yup.string().when('type', { is: 'dockerfile', then: (schema) => schema, // no-op: zero constraints applied }),Unlike the
gitbranch—which applies.shape()with a requiredurlfield whentype === 'git'—thedockerfilefield remains unconstrained whentype === 'dockerfile'. If the form should require Dockerfile content/path in that mode, add.required(i18n.t('devconsole~Required'))to thethencallback. If it is intentionally optional, document that expectation or confirm with your test suite.frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (4)
13-26: LGTM: Correct Yup 1.x migration pattern.The conditional validation logic has been correctly migrated to Yup 1.x's functional callback pattern. The use of
schema.concat()on line 25 properly composes the URI validation schema.
48-51: Verify the no-op conditional branch.The
CamelKameletBindingModel.kindbranch returns the schema unchanged (then: (schema) => schema). Please confirm whether this is intentional (to explicitly document that this type requires no additional validation) or if this conditional branch can be removed.
53-68: LGTM: Correct schema composition.The form validation logic has been correctly migrated to use the functional
thencallback, properly composing all nested validation schemas (project, application, name, source, data).
13-68: Address Biome linter false positives.The Biome linter is flagging
lint/suspicious/noThenPropertyerrors on lines 18, 25, 33, 50, and 58. These are false positives—thethenproperty is part of Yup's conditional validation API (.when()configuration object) and is not related to Promise chaining.Consider updating the Biome configuration to exclude this rule for Yup validation schema files, or add inline suppressions to prevent confusion:
// biome-ignore lint/suspicious/noThenProperty: Yup DSL requires 'then' property then: (schema) => schema.shape({ ... })
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (1)
112-119: Schema concatenation is correct.The use of
schema.concat()on line 116 correctly merges the webhook validation schema, following the Yup 1.x composition pattern.The webhook validation logic in
repositoryValidationSchema(lines 44-73) andpipelinesAccessTokenValidationSchema(lines 78-109) is duplicated. Consider extracting the webhook validation into a shared helper function to reduce duplication and maintenance burden:const webhookValidationShape = (t: TFunction) => ({ webhook: yup .object() .when('gitProvider', { is: GitProvider.BITBUCKET, then: (schema) => schema.shape({ user: yup.string() .matches(bitBucketUserNameRegex, { message: t('pipelines-plugin~Name must consist of lower-case letters, numbers, underscores and hyphens. It must start with a letter and end with a letter or number.'), excludeEmptyString: true, }) .required(t('pipelines-plugin~Required')), }), }) .when(['method', 'gitProvider', 'gitUrl'], { is: (method, gitProvider, gitUrl) => gitUrl && !(gitProvider === GitProvider.GITHUB && method === GitProvider.GITHUB), then: (schema) => schema.shape({ token: yup.string().test('oneOfRequired', 'Required', function () { return this.parent.token || this.parent.secretRef; }), secretRef: yup.string().test('oneOfRequired', 'Required', function () { return this.parent.token || this.parent.secretRef; }), }), }), });Then use it in both schemas:
export const repositoryValidationSchema = (t: TFunction) => yup.object().shape({ name: yup.string()..., gitUrl: yup.string()..., accessToken: yup.string(), ...webhookValidationShape(t), });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (3)
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts(1 hunks)frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts(1 hunks)frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.tsfrontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.tsfrontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts
🪛 Biome (2.1.2)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 100-100: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
🔇 Additional comments (4)
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts (1)
8-8: LGTM! Test correctly updated for new data structure.The test properly reflects the updated mock data structure, accessing the name field via the nested
subjectobject. The test logic and validation assertions remain intact.frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts (1)
6-9: Data structure change verified and approved.Verification confirms the validation schema in
project-access-form-validation-utils.ts(lines 7–10) expects the exact nestedsubjectstructure introduced in your change. The test data structure at lines 6–9 aligns perfectly with the schema requirements.frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (2)
28-110: Yup 1.x migration looks correct.The conversion from object-based
thento functional callbacks(schema) => schema.shape(...)correctly follows the Yup 1.x API. The synchronous test functions (lines 66-71, 102-107) are valid since they only check properties without async operations. The previous issue withnameRegexvsbitBucketUserNameRegexhas been properly addressed.
48-48: Biome warnings are false positives.The static analysis warnings about "Do not add then to an object" are false positives. These lines correctly use Yup 1.x's conditional validation API where
thenis a property that takes a function(schema) => .... This is not the Promise anti-pattern that Biome'snoThenPropertyrule is designed to catch.Consider suppressing these warnings or configuring Biome to ignore
thenproperties withinyup.when()calls.Also applies to: 64-64, 82-82, 100-100, 116-116
|
/label px-approved |
|
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.ts (1)
2-2: ValidationError typing in tests is workable but loosely typedImporting
ValidationErrorand casting POJOs to that type is fine for these tests since onlyinner[].pathis exercised, but it sidesteps type safety. If you want stricter typings later, consider usingPick<ValidationError, 'inner'>or a small local interface instead of a fullValidationErrorcast.Also applies to: 107-107, 123-123, 141-141, 164-164
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (1)
48-51: Consider removing no-op validation branch.The
then: (schema) => schemafor CamelKameletBinding is functionally a no-op. If no additional validation is needed, this branch could be removed for clarity.- .when('type', { - is: CamelKameletBindingModel.kind, - then: (schema) => schema, - }); + });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (24)
frontend/package.json(1 hunks)frontend/packages/dev-console/locales/en/devconsole.json(0 hunks)frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts(3 hunks)frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/hpa/validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/validation-schema.ts(10 hunks)frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts(1 hunks)frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts(1 hunks)frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts(2 hunks)frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx(1 hunks)frontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx(1 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts(3 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.ts(5 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts(3 hunks)frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts(2 hunks)frontend/packages/shipwright-plugin/src/components/build-form/validation.ts(1 hunks)frontend/packages/vsphere-plugin/package.json(1 hunks)frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts(1 hunks)frontend/public/components/configmaps/configmap-utils.ts(1 hunks)
💤 Files with no reviewable changes (1)
- frontend/packages/dev-console/locales/en/devconsole.json
🚧 Files skipped from review as they are similar to previous changes (3)
- frontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx
- frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts
- frontend/packages/dev-console/src/components/project-access/tests/project-access-form-validation-utils.spec.ts
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/shipwright-plugin/src/components/build-form/validation.tsfrontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.tsfrontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.tsfrontend/packages/dev-console/src/components/hpa/validation-utils.tsfrontend/package.jsonfrontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.tsfrontend/packages/dev-console/src/components/buildconfig/form-utils/validation.tsfrontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.tsfrontend/public/components/configmaps/configmap-utils.tsfrontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.tsfrontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.tsfrontend/packages/vsphere-plugin/package.jsonfrontend/packages/dev-console/src/components/import/validation-schema.tsfrontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.tsfrontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.tsfrontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.tsfrontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.tsfrontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsxfrontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.tsfrontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts
🧬 Code graph analysis (12)
frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts (2)
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
projectNameValidationSchema(31-39)applicationNameValidationSchema(41-50)frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/dev-console/src/components/hpa/validation-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (1)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/types.ts (1)
PipelineBuilderFormYamlValues(64-69)
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (2)
frontend/packages/dev-console/src/components/buildconfig/form-utils/types.ts (1)
BuildConfigFormikValues(13-25)frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
formDataSchema(35-42)
frontend/public/components/configmaps/configmap-utils.ts (1)
frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
formDataSchema(35-42)
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (4)
frontend/__mocks__/i18next.ts (1)
t(8-14)frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
sinkTypeUriValidation(11-20)frontend/packages/knative-plugin/src/models.ts (2)
KafkaSinkModel(284-300)CamelKameletBindingModel(248-264)frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
projectNameValidationSchema(31-39)applicationNameValidationSchema(41-50)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
frontend/__mocks__/i18next.ts (1)
t(8-14)frontend/public/components/utils/units.js (1)
value(225-225)
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts (5)
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (1)
validationSchema(85-106)frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts (1)
validationSchema(33-48)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (1)
validationSchema(477-492)frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
validationSchema(44-66)frontend/public/components/configmaps/configmap-utils.ts (1)
validationSchema(198-219)
frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
projectNameValidationSchema(31-39)applicationNameValidationSchema(41-50)
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx (2)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
sinkTypeUriValidation(11-20)frontend/__mocks__/i18next.ts (1)
t(8-14)
🪛 Biome (2.1.2)
frontend/packages/shipwright-plugin/src/components/build-form/validation.ts
[error] 54-54: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 58-58: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts
[error] 15-15: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/hpa/validation-utils.ts
[error] 12-12: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts
[error] 485-485: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts
[error] 17-17: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 28-28: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 38-38: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 49-49: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 53-53: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 95-95: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 99-99: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/public/components/configmaps/configmap-utils.ts
[error] 208-208: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 212-212: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts
[error] 18-18: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 25-25: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 33-33: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 50-50: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 58-58: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 100-100: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/import/validation-schema.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 188-188: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 301-301: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 317-317: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 328-328: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 340-340: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 375-375: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 125-125: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 140-140: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts
[error] 16-16: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 45-45: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 56-56: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 63-63: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts
[error] 41-41: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts
[error] 27-27: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 34-34: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 42-42: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 55-55: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 97-97: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 146-146: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 167-167: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 184-184: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts
[error] 14-14: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 22-22: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 29-29: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 38-38: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 49-49: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 74-74: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 89-89: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 104-104: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 113-113: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts
[error] 23-23: Do not add then to an object.
(lint/suspicious/noThenProperty)
🔇 Additional comments (26)
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts (1)
6-9: LGTM! Improved mock data structure.The change from a flat
userstring to a structuredsubjectobject improves consistency with other mock data in this file and aligns with the expected type structure.frontend/packages/vsphere-plugin/package.json (1)
12-12: Verify that vsphere-plugin validation code has been migrated to Yup 1.x patterns.The dependency was bumped from 0.27.0 to 1.7.1, which is a major version upgrade with breaking changes. The PR objectives mention migrating 20+ validation files across multiple plugins (helm, knative, pipelines, shipwright, webterminal, metal3), but vsphere-plugin is not explicitly listed in the modified files.
Please confirm:
- If vsphere-plugin contains validation schemas using yup, verify they have been updated to Yup 1.x patterns (e.g., async
.test()handlers, function-based.then()clauses,schema.concat()for composition).- If vsphere-plugin does not directly use yup, confirm that the dependency bump does not create runtime incompatibilities.
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (1)
48-116: LGTM! Yup 1.x migration is correct.All validation schemas have been correctly migrated to Yup 1.x:
- Functional
then: (schema) => schema.shape(...)callbacks replace static objects (lines 48-59, 64-72, 82-93, 100-108)schema.concat()properly merges schemas (line 116)bitBucketUserNameRegexconsistently used for BITBUCKET provider validation in both schemas (lines 52, 86)- Synchronous test functions for
oneOfRequiredvalidation remain appropriately synchronousNote: The Biome
lint/suspicious/noThenPropertyerrors are false positives—thenis a valid Yup API property in.when()configuration. Consider suppressing this rule for Yup schema files or updating Biome configuration.frontend/package.json (1)
220-220: Yup major version bump – rely on validation test coverageBumping to
^1.7.1is consistent with the rest of the PR’s schema changes; no issues in this file. Given it’s a major upgrade, just ensure the targeted validation suites and key UI flows (Pipelines, BuildConfig, Deployment, ConfigMap, Helm, Knative) have been exercised after this change.frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts (1)
23-29: Conditional namespace validation preserved under new callback styleThe functional
thencallback keeps the existing behavior:newNamespacebecomes required and regex‑validated only whennamespace === CREATE_NAMESPACE_KEY, and remains an optional string otherwise. This looks correct and consistent withCloudShellSetupFormData.frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
46-47: Async wrapper around inner form/YAML schema is correctMaking the test async, awaiting
formYamlDefinition.validate(values, { abortEarly: false }), and returningtrueon success is the right pattern for Yup 1.x; failures will surface via the thrownValidationError. The functionalthenbranches forformDataandyamlDatacorrectly compose additional constraints without discarding the base schema.Also applies to: 54-55, 58-60, 63-64
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx (1)
80-83: Sink URI validation correctly composed with base schemaUsing
then: (schema) => schema.concat(sinkTypeUriValidation(t))keeps the URI‑specific rules while preserving any existing constraints onsink(now or in future). This is compatible with the currentinitialValuesshape and Yup 1.x composition semantics.frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts (1)
15-20: LGTM: Correct Yup 1.x migration pattern.The functional
thencallback correctly implements the Yup 1.x breaking change. The static analysis warning about thethenproperty is a false positive—thenis a valid API in Yup'swhen()clauses.frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
16-68: LGTM: Nested validation schemas migrated correctly.The functional
thencallbacks across all nested branches (showForm, httpGet, tcpSocket, exec) correctly implement the Yup 1.x pattern while preserving validation semantics.frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts (1)
35-46: LGTM: Async validation correctly implemented.The async test with
schema.concat()composition and explicit boolean return correctly implements the Yup 1.x async validation pattern.frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts (2)
116-128: LGTM: Conditional validation schemas migrated correctly.Both
imageStreamandisivalidation branches correctly use functionalthencallbacks per Yup 1.x requirements.
134-145: LGTM: Async validation pattern implemented correctly.The async test with
schema.concat()and explicit boolean return follows the Yup 1.x async validation pattern.frontend/public/components/configmaps/configmap-utils.ts (1)
200-217: LGTM: Async validation with dual editor support.The async validation correctly handles both Form and YAML editor types using
schema.concat()composition, following Yup 1.x patterns.frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (2)
282-282: LGTM: Explicit boolean coercion improves clarity.The
!!operator makes the boolean coercion explicit while remaining functionally equivalent to the previous truthy checks.Also applies to: 394-394
479-490: LGTM: Async validation pattern correctly applied.The async test with
schema.concat()and boolean return follows the Yup 1.x async validation requirements.frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (3)
18-26: LGTM: Source type validation migrated correctly.Both Resource and Uri validation branches correctly use functional
thencallbacks with appropriate composition viaschema.concat().
33-46: LGTM: Nested KafkaSink validation correctly structured.The deeply nested validation for KafkaSink correctly uses functional
thencallback with proper shape augmentation.
58-65: LGTM: Event sink form validation migrated correctly.The functional
thencallback withschema.shape()correctly implements Yup 1.x requirements for the form editor validation.frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts (3)
14-53: LGTM: Resource type validations migrated correctly.All resource type validations (git, image, storage, cluster) and secrets validation correctly use functional
thencallbacks following Yup 1.x patterns.
64-64: LGTM: Schema composition using concat.The use of
schema.concat()for conditional resource validation follows the correct Yup 1.x composition pattern.
74-129: LGTM: Volume type validations with deep nesting migrated correctly.All volume type validations (Secret, ConfigMap, PVC, VolumeClaimTemplate) correctly implement the functional
thencallback pattern with properly structured nested shapes.frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
214-296: Resource limits/request validation changes look consistentThe additions of
.nullable()on numericrequest/limitfields and the explicitrequestUnit/limitUnitstring fields keep the existing cross-fieldconvertToBaseValuecomparisons intact while improving handling of optional values. No functional regressions or major issues spotted here.
41-50: Yup 1.xwhen→ functionalthenmigration looks correctAcross these schemas (
applicationNameValidationSchema, route TLS, image/git/docker/devfile/importFlow/ISI validators), the move to function-basedthen: (schema) => schema.shape(...)orschema.required(...)preserves the prior conditions and requiredness while aligning with Yup 1.x’s composition patterns. No shape/path regressions or obvious behavior changes beyond the intended async-aware refactor.Also applies to: 183-212, 298-306, 308-324, 325-335, 337-350, 359-367, 369-379
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
22-36: Conditional event source schemas and form validators look sound
sinkServiceSchemacorrectly distinguishesSinkType.Resource(requiringname) fromSinkType.Uri(delegating tosinkTypeUriValidation), without altering other sink shapes.sourceDataSpecSchemabranches (PingSource, SinkBinding, ApiServerSource, KafkaSource, ContainerSource) usethen: (schema) => schema.shape(...)to add nested constraints without changing the outertypecontract. The SinkBinding rule that only requiressubject.namewhenselector.matchLabelsis absent is especially clear.eventSourceValidationSchemaandaddChannelValidationSchemaconditionally refineformDataonly forEditorType.Form, reusing the shared project/application/name schemas consistently.No structural/path issues or unintended requirement changes stand out here.
Also applies to: 37-160, 162-194
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (2)
33-55: Image and top-level buildconfig validation migrations look correct
imageSchema’swhenbranches now applyrequiredand nestedimageStreamfields via function-basedthen, preserving previous behavior while aligning with Yup 1.x composition.- The top-level
validationSchemaasynctestthat delegates toformYamlDefinition.validate(values, { abortEarly: false })cleanly centralizes all field validation for bothEditorType.FormandEditorType.YAMLwithout changing public shape.No additional issues or regressions are evident in these sections.
Also applies to: 85-105
8-31: The review comment is incorrect—the schema correctly validates the actual data structure.The codebase consistently uses a nested structure
source.git.git.*(notsource.git.*as the reviewer assumed):
- Test expectations show
formData.source.git.git.url,formData.source.git.git.ref, andformData.source.git.git.dir- The initial data setup confirms this same nesting
- The validation schema's
schema.shape({ git: yup.object({...}) })correctly applies validation to this nested structureThe reviewer's concern assumed a "natural" form shape of
source.git.url, but the actual form data throughout the codebase uses the nested path. The schema is correct as written and requires no changes.
| minReplicas: yup | ||
| .number() | ||
| .test(isInteger(t('devconsole~Minimum Pods must be an integer.'))) | ||
| .min(1, t('devconsole~Minimum Pods must greater than or equal to 1.')) | ||
| .test( | ||
| 'test-less-than-max', | ||
| t('devconsole~Minimum Pods should be less than or equal to Maximum Pods.'), | ||
| function (minReplicas) { | ||
| const { maxReplicas } = this.parent; | ||
| return minReplicas <= maxReplicas; | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make cross-field minReplicas/maxReplicas checks null-safe to avoid unintended validation failures
As written, the cross-field tests assume both minReplicas and maxReplicas are always present and that this.parent is never undefined:
- If a user sets
maxReplicaswhileminReplicasis still empty/undefined, themaxReplicastest will still run and evaluateminReplicas <= maxReplicas, which can fail purely becauseminReplicasis unset. That effectively makesminReplicasrequired even though the schema does not mark it as required. - The same pattern exists on the
minReplicasside, and both tests destructurethis.parentwithout a guard, which is fragile if the parent shape is ever absent or restructured.
To keep the UX predictable and avoid spurious cross-field errors, it’s safer to:
- Skip the relational checks when either side is
null/undefined. - Guard
this.parentbefore destructuring.
Example patch:
spec: yup.object({
minReplicas: yup
.number()
.test(isInteger(t('devconsole~Minimum Pods must be an integer.')))
.min(1, t('devconsole~Minimum Pods must greater than or equal to 1.'))
.test(
'test-less-than-max',
t('devconsole~Minimum Pods should be less than or equal to Maximum Pods.'),
function (minReplicas) {
- const { maxReplicas } = this.parent;
- return minReplicas <= maxReplicas;
+ const { maxReplicas } = this.parent || {};
+ if (minReplicas == null || maxReplicas == null) {
+ // Don’t enforce cross-field constraint until both values are set
+ return true;
+ }
+ return minReplicas <= maxReplicas;
},
),
maxReplicas: yup
.number()
.test(isInteger(t('devconsole~Maximum Pods must be an integer.')))
.max(
Number.MAX_SAFE_INTEGER,
t('devconsole~Value is larger than maximum value allowed.'),
)
.test(
'test-greater-than-min',
t('devconsole~Maximum Pods should be greater than or equal to Minimum Pods.'),
function (maxReplicas) {
- const { minReplicas } = this.parent;
- return minReplicas <= maxReplicas;
+ const { minReplicas } = this.parent || {};
+ if (minReplicas == null || maxReplicas == null) {
+ // Only validate the relationship when both sides are present
+ return true;
+ }
+ return minReplicas <= maxReplicas;
},
)
.required(t('devconsole~Max Pods must be defined.')),
}),This keeps the intended invariant (minReplicas <= maxReplicas) while avoiding turning minReplicas into an implicit required field and makes the validation more robust to shape changes.
Also applies to: 39-54
🤖 Prompt for AI Agents
In frontend/packages/dev-console/src/components/hpa/validation-utils.ts around
lines 27-37 (and similarly 39-54), the cross-field tests for
minReplicas/maxReplicas assume this.parent exists and both values are present,
causing spurious failures when one side is undefined; update the test callbacks
to guard this.parent before destructuring and return true (skip the relational
check) if either minReplicas or maxReplicas is null/undefined so the
relationship check only runs when both values are set.
| export const serverlessValidationSchema = (t: TFunction) => | ||
| yup.object().when('resources', { | ||
| is: Resources.KnativeService, | ||
| then: yup.object().shape({ | ||
| scaling: yup.object({ | ||
| minpods: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Min Pods must be an integer.'))) | ||
| .min(0, t('devconsole~Min Pods must be greater than or equal to 0.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t('devconsole~Min Pods must be lesser than or equal to {{maxSafeInteger}}.', { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }), | ||
| ), | ||
| maxpods: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Max Pods must be an integer.'))) | ||
| .min(1, t('devconsole~Max Pods must be greater than or equal to 1.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t('devconsole~Max Pods must be lesser than or equal to {{maxSafeInteger}}.', { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }), | ||
| ) | ||
| .test({ | ||
| test(limit) { | ||
| const { minpods } = this.parent; | ||
| return limit ? limit >= minpods : true; | ||
| }, | ||
| message: t('devconsole~Max Pods must be greater than or equal to Min Pods.'), | ||
| }), | ||
| concurrencytarget: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Concurrency target must be an integer.'))) | ||
| .min(0, t('devconsole~Concurrency target must be greater than or equal to 0.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t('devconsole~Concurrency target must be lesser than or equal to {{maxSafeInteger}}.', { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }), | ||
| ), | ||
| concurrencylimit: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Concurrency limit must be an integer.'))) | ||
| .min(0, t('devconsole~Concurrency limit must be greater than or equal to 0.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t('devconsole~Concurrency limit must be lesser than or equal to {{maxSafeInteger}}.', { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }), | ||
| ), | ||
| concurrencyutilization: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .min(0, t('devconsole~Concurrency utilization must be between 0 and 100.')) | ||
| .max(100, t('devconsole~Concurrency utilization must be between 0 and 100.')), | ||
| autoscale: yup.object().shape({ | ||
| autoscalewindow: yup | ||
| then: (schema) => | ||
| schema.shape({ | ||
| scaling: yup.object({ | ||
| minpods: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Min Pods must be an integer.'))) | ||
| .min(0, t('devconsole~Min Pods must be greater than or equal to 0.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t('devconsole~Min Pods must be lesser than or equal to {{maxSafeInteger}}.', { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }), | ||
| ), | ||
| maxpods: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Max Pods must be an integer.'))) | ||
| .min(1, t('devconsole~Max Pods must be greater than or equal to 1.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t('devconsole~Max Pods must be lesser than or equal to {{maxSafeInteger}}.', { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }), | ||
| ) | ||
| .test({ | ||
| test(autoscalewindow) { | ||
| if (autoscalewindow) { | ||
| const { autoscalewindowUnit } = this.parent; | ||
| const value = convertToSec(autoscalewindow, autoscalewindowUnit); | ||
| return value >= 6 && value <= 3600; | ||
| } | ||
| return true; | ||
| test(limit) { | ||
| const { minpods } = this.parent; | ||
| return limit ? limit >= minpods : true; | ||
| }, | ||
| message: t('devconsole~Autoscale window must be between 6s and 1h.'), | ||
| message: t('devconsole~Max Pods must be greater than or equal to Min Pods.'), | ||
| }), | ||
| concurrencytarget: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Concurrency target must be an integer.'))) | ||
| .min(0, t('devconsole~Concurrency target must be greater than or equal to 0.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t( | ||
| 'devconsole~Concurrency target must be lesser than or equal to {{maxSafeInteger}}.', | ||
| { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }, | ||
| ), | ||
| ), | ||
| concurrencylimit: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test(isInteger(t('devconsole~Concurrency limit must be an integer.'))) | ||
| .min(0, t('devconsole~Concurrency limit must be greater than or equal to 0.')) | ||
| .max( | ||
| Number.MAX_SAFE_INTEGER, | ||
| t( | ||
| 'devconsole~Concurrency limit must be lesser than or equal to {{maxSafeInteger}}.', | ||
| { | ||
| maxSafeInteger: Number.MAX_SAFE_INTEGER, | ||
| }, | ||
| ), | ||
| ), | ||
| concurrencyutilization: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .min(0, t('devconsole~Concurrency utilization must be between 0 and 100.')) | ||
| .max(100, t('devconsole~Concurrency utilization must be between 0 and 100.')), | ||
| autoscale: yup.object().shape({ | ||
| autoscalewindow: yup | ||
| .number() | ||
| .transform((cv) => (_.isNaN(cv) ? undefined : cv)) | ||
| .test({ | ||
| test(autoscalewindow) { | ||
| if (autoscalewindow) { | ||
| const { autoscalewindowUnit } = this.parent; | ||
| const value = convertToSec(autoscalewindow, autoscalewindowUnit); | ||
| return value >= 6 && value <= 3600; | ||
| } | ||
| return true; | ||
| }, | ||
| message: t('devconsole~Autoscale window must be between 6s and 1h.'), | ||
| }), | ||
| }), | ||
| }), | ||
| }), | ||
| domainMapping: yup.array().of( | ||
| yup | ||
| .string() | ||
| .transform(removeKsvcInfoFromDomainMapping) | ||
| .matches(hostnameRegex, { | ||
| message: t( | ||
| 'devconsole~Domain name must consist of lower-case letters, numbers, periods, and hyphens. It must start and end with a letter or number.', | ||
| domainMapping: yup.array().of( | ||
| yup | ||
| .string() | ||
| .transform(removeKsvcInfoFromDomainMapping) | ||
| .matches(hostnameRegex, { | ||
| message: t( | ||
| 'devconsole~Domain name must consist of lower-case letters, numbers, periods, and hyphens. It must start and end with a letter or number.', | ||
| ), | ||
| excludeEmptyString: true, | ||
| }) | ||
| .test( | ||
| 'domainname-has-segements', | ||
| t('devconsole~Domain name must consist of at least two segments separated by dots.'), | ||
| function (domainName: string) { | ||
| return domainName.split('.').length >= 2; | ||
| }, | ||
| ), | ||
| excludeEmptyString: true, | ||
| }) | ||
| .test( | ||
| 'domainname-has-segements', | ||
| t('devconsole~Domain name must consist of at least two segments separated by dots.'), | ||
| function (domainName: string) { | ||
| return domainName.split('.').length >= 2; | ||
| }, | ||
| ), | ||
| ), | ||
| }), | ||
| ), | ||
| }), | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix edge cases in autoscale window and domainMapping validation
Two subtle correctness issues here:
autoscalewindowtest (Lines 145-160): usingif (autoscalewindow)treats0as “no value”, so a value of0seconds silently bypasses the6–3600range check, despite the error message saying “must be between 6s and 1h.” Consider explicitly checking fornull/undefinedand always validating numeric0:
- .test({
- test(autoscalewindow) {
- if (autoscalewindow) {
+ .test({
+ test(autoscalewindow) {
+ if (autoscalewindow !== null && autoscalewindow !== undefined) {
const { autoscalewindowUnit } = this.parent;
const value = convertToSec(autoscalewindow, autoscalewindowUnit);
return value >= 6 && value <= 3600;
}
return true;
},domainname-has-segementstest (Lines 172-177):domainNamecan beundefinedor an empty string (especially withexcludeEmptyString: trueon the precedingmatches), in which casedomainName.split('.')can throw or incorrectly flag empty values. Guard against falsy values so blanks are ignored and only non-empty hostnames are checked:
- .test(
- 'domainname-has-segements',
- t('devconsole~Domain name must consist of at least two segments separated by dots.'),
- function (domainName: string) {
- return domainName.split('.').length >= 2;
- },
- ),
+ .test(
+ 'domainname-has-segements',
+ t('devconsole~Domain name must consist of at least two segments separated by dots.'),
+ function (domainName?: string | null) {
+ if (!domainName) {
+ return true;
+ }
+ return domainName.split('.').length >= 2;
+ },
+ ),These changes keep the intended messages while avoiding silent acceptance of 0 and runtime errors on empty/undefined domain names.
🧰 Tools
🪛 Biome (2.1.2)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
🤖 Prompt for AI Agents
In frontend/packages/dev-console/src/components/import/validation-schema.ts
around lines 145-160 and 172-177, the autoscalewindow test treats 0 as "no
value" and the domainMapping test can throw or mis-handle empty/undefined domain
names; update the autoscalewindow validator to explicitly check for
null/undefined (e.g., if (autoscalewindow === null || autoscalewindow ===
undefined) return true) so numeric 0 is validated against the 6–3600 range, and
update the domainname-has-segements test to guard for falsy/empty values (return
true for empty or undefined) and only call split('.') when domainName is a
non-empty string so blanks are ignored and no runtime error occurs.
|
/retest |
|
@krishagarwal278: This PR has been marked to be verified later by In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/packages/integration-tests-cypress/views/details-page.ts (1)
2-5: Chain Cypress commands for better efficiency and readability.The function queries
[data-test="page-heading"]twice, which is inefficient and not idiomatic Cypress usage. Chain the commands to reduce duplication and improve maintainability.Apply this diff to chain the commands:
titleShouldContain: (title: string) => { - cy.get('[data-test="page-heading"]', { timeout: 30000 }).should('be.visible'); - cy.get('[data-test="page-heading"]').contains(title, { timeout: 30000 }); + cy.get('[data-test="page-heading"]', { timeout: 30000 }) + .should('be.visible') + .and('contain', title); },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (3)
frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx(2 hunks)frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts(1 hunks)frontend/packages/integration-tests-cypress/views/details-page.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.tsfrontend/packages/integration-tests-cypress/views/details-page.tsfrontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx
🔇 Additional comments (3)
frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts (1)
137-146: Excellent approach for handling async validation timing.The implementation correctly addresses race conditions with Yup 1.x async validation by:
- Directly setting the textarea value instead of typing character-by-character
- Dispatching both
inputandchangeevents withbubbles: trueto trigger React handlers- Synchronizing on the save button becoming enabled before proceeding
This ensures the JSON is validated as a complete payload and the test waits for validation to complete.
frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx (2)
77-77: LGTM: Normalized status propagated to form state.Explicitly setting the
isi.statusfield value ensures the normalized status is available for Formik validation and downstream form logic. This complements the isi object construction and supports the migration to Yup 1.x validation patterns.
59-68: Normalization logic is correct and properly justified.Verification confirms the concern is unfounded. The isiValidationSchema requires
status.statusto be a non-empty string, and the normalization in lines 59-68 is the correct approach:
Schema requirement met: The validation schema defines
status: yup.object().shape({ status: yup.string().required(...) }), meaningstatus.statusmust exist and be a string.'Success' is semantically appropriate: The code executes in the
.then()block of a successfulk8sGetcall, so the resource fetch succeeded. ImageSearch.tsx (line 129) explicitly checksif (status.status === 'Success'), confirming 'Success' is an intentional, valid status value for successful operations.Error cases handled separately: Error paths set
status: ''(empty string), properly distinguishing error states from success states.No semantic misrepresentation: The schema accepts any string value, not just 'Success', so legitimate non-success states with different status values would pass through unchanged.
The comment accurately explains the rationale, and the implementation correctly addresses the validation schema requirements introduced by the Yup upgrade.
| // Paste JSON directly instead of typing character-by-character to avoid | ||
| // race condition with JSON.parse validation running on incomplete data. | ||
| // See: https://issues.redhat.com/browse/OCPBUGS-XXXXX (yup 1.x timing issue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace or remove the placeholder JIRA reference.
The comment contains a placeholder ticket ID "OCPBUGS-XXXXX". Either replace it with the actual JIRA issue number or remove the reference if no specific ticket exists.
- // Paste JSON directly instead of typing character-by-character to avoid
- // race condition with JSON.parse validation running on incomplete data.
- // See: https://issues.redhat.com/browse/OCPBUGS-XXXXX (yup 1.x timing issue)
+ // Paste JSON directly instead of typing character-by-character to avoid
+ // race condition with JSON.parse validation running on incomplete data.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Paste JSON directly instead of typing character-by-character to avoid | |
| // race condition with JSON.parse validation running on incomplete data. | |
| // See: https://issues.redhat.com/browse/OCPBUGS-XXXXX (yup 1.x timing issue) | |
| // Paste JSON directly instead of typing character-by-character to avoid | |
| // race condition with JSON.parse validation running on incomplete data. |
🤖 Prompt for AI Agents
In
frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts
around lines 134 to 136, the inline comment references a placeholder JIRA ticket
"OCPBUGS-XXXXX"; replace that placeholder with the real JIRA issue number if
known or remove the JIRA reference entirely so the comment reads clearly (e.g.,
keep the explanation about pasting JSON to avoid the yup timing issue but omit
the bogus ticket ID).
4fb8d87 to
f374728
Compare
f374728 to
29f6b0d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/packages/integration-tests-cypress/views/secret.ts (1)
35-41: Avoid hard‑codedcy.wait(500)where a state-based wait would workThe added explicit visibility wait and forced click should help with flakiness, but the unconditional
cy.wait(500)is a magic delay that slows tests and can mask underlying timing issues. If possible, consider replacing it with a condition-based check on the button or resulting content (e.g.,should('not.be.disabled'),should('not.have.attr', 'aria-busy', 'true'), or waiting for the revealed values container to appear) so the helper synchronizes on UI state instead of a fixed sleep.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (4)
frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx(2 hunks)frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts(1 hunks)frontend/packages/integration-tests-cypress/views/details-page.ts(1 hunks)frontend/packages/integration-tests-cypress/views/secret.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/packages/integration-tests-cypress/views/details-page.ts
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/integration-tests-cypress/views/secret.tsfrontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.tsfrontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx
🧬 Code graph analysis (1)
frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts (1)
frontend/packages/integration-tests-cypress/views/secret.ts (1)
secrets(6-71)
🔇 Additional comments (3)
frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts (1)
133-147: Async validation handling in Cypress test looks solidThe slower JSON typing plus the explicit wait for the Save button to become enabled should make this flow much more robust against async Yup validation timing, and the URL assertion adds a clear check that we actually navigated to the details page. No issues spotted here.
Please ensure this spec is stable by running the relevant Cypress test suite (or this spec in isolation) a few times locally/CI to confirm there’s no remaining flakiness around the config‑file validation.
frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx (2)
77-77: LGTM!Explicitly setting the
isi.statusfield ensures the normalized status is available in the form state for validation. This change is consistent with how otherisifields are populated.
59-68: Verify that defaulting to 'Success' is correct for all ImageStreamTag responses.The normalization logic assumes that if
status.statusis missing, the status should default to'Success'. This assumption could mask actual failures or non-success states if the ImageStreamTag API returns a status object without the nestedstatus.statusproperty for scenarios other than success.Confirm that:
- The ImageStreamTag API response structure guarantees that missing
status.statusalways indicates success- The validation schema expectations after upgrading Yup from 0.27.0 to 1.7.1 require this normalization
- Alternative scenarios (e.g., import in progress, import failed) are handled correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
frontend/packages/dev-console/src/components/hpa/validation-utils.ts (1)
12-55: MakeminReplicas/maxReplicascross-field checks null‑safeThese tests still assume both fields are always present:
- If a user fills
maxReplicaswhileminReplicasis empty, theminReplicas <= maxReplicascheck can fail purely becauseminReplicasis unset, effectively making it implicitly required.- Both tests destructure
this.parentwithout guarding it, which is brittle.Guard both sides and
this.parentso the relation is only enforced when both values are set:spec: yup.object({ minReplicas: yup .number() .test(isInteger(t('devconsole~Minimum Pods must be an integer.'))) .min(1, t('devconsole~Minimum Pods must greater than or equal to 1.')) .test( 'test-less-than-max', t('devconsole~Minimum Pods should be less than or equal to Maximum Pods.'), function (minReplicas) { - const { maxReplicas } = this.parent; - return minReplicas <= maxReplicas; + const { maxReplicas } = this.parent || {}; + if (minReplicas == null || maxReplicas == null) { + // Skip relational check until both values are provided + return true; + } + return minReplicas <= maxReplicas; }, ), maxReplicas: yup .number() .test(isInteger(t('devconsole~Maximum Pods must be an integer.'))) .max( Number.MAX_SAFE_INTEGER, t('devconsole~Value is larger than maximum value allowed.'), ) .test( 'test-greater-than-min', t('devconsole~Maximum Pods should be greater than or equal to Minimum Pods.'), function (maxReplicas) { - const { minReplicas } = this.parent; - return minReplicas <= maxReplicas; + const { minReplicas } = this.parent || {}; + if (minReplicas == null || maxReplicas == null) { + // Only enforce relation once both fields are populated + return true; + } + return maxReplicas >= minReplicas; }, ) .required(t('devconsole~Max Pods must be defined.')), }),This keeps the intended invariant while avoiding spurious errors when only one side is filled.
frontend/packages/dev-console/src/components/import/validation-schema.ts (1)
80-181: Fixautoscalewindowand domainMapping edge cases in serverless validationTwo spots here can produce incorrect or surprising behavior:
autoscalewindowrange check (Lines 145-160)
- The
if (autoscalewindow)guard treats0as “no value”, so0seconds bypasses the6–3600range check despite the error message.- It’s safer to explicitly check for
null/undefinedand always validate numeric0:autoscale: yup.object().shape({ autoscalewindow: yup .number() .transform((cv) => (_.isNaN(cv) ? undefined : cv)) .test({ - test(autoscalewindow) { - if (autoscalewindow) { + test(autoscalewindow) { + if (autoscalewindow !== null && autoscalewindow !== undefined) { const { autoscalewindowUnit } = this.parent; const value = convertToSec(autoscalewindow, autoscalewindowUnit); return value >= 6 && value <= 3600; } return true; },
domainname-has-segementstest (Lines 172-177)
domainNamecan beundefinedor empty (especially withexcludeEmptyString: trueon the precedingmatches), but the test unconditionally callsdomainName.split('.'), which can throw or incorrectly flag empty values.- Guard for falsy values and only split non-empty strings:
domainMapping: yup.array().of( yup .string() .transform(removeKsvcInfoFromDomainMapping) .matches(hostnameRegex, { message: t( 'devconsole~Domain name must consist of lower-case letters, numbers, periods, and hyphens. It must start and end with a letter or number.', ), excludeEmptyString: true, }) .test( 'domainname-has-segements', t('devconsole~Domain name must consist of at least two segments separated by dots.'), - function (domainName: string) { - return domainName.split('.').length >= 2; - }, + function (domainName?: string | null) { + if (!domainName) { + // Empty/undefined already handled by the previous matcher + return true; + } + return domainName.split('.').length >= 2; + }, ), ),These changes enforce the documented constraints while avoiding silent acceptance of
0and runtime issues on empty hostnames.
🧹 Nitpick comments (5)
frontend/packages/integration-tests-cypress/views/details-page.ts (1)
2-5: Consider chaining Cypress commands to avoid redundant queries.The same selector is queried twice in succession. A more idiomatic Cypress pattern would chain the commands:
Apply this diff to chain the commands:
titleShouldContain: (title: string) => { - cy.get('[data-test="page-heading"]', { timeout: 30000 }).should('be.visible'); - cy.get('[data-test="page-heading"]').contains(title, { timeout: 30000 }); + cy.get('[data-test="page-heading"]', { timeout: 30000 }) + .should('be.visible') + .and('contain', title); },This improves maintainability by reducing duplication and follows Cypress best practices for command chaining.
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (1)
50-50: Consider clarifying intent of identity schema transformation.The
then: (schema) => schemareturns the schema unchanged. If no additional validation is needed forCamelKameletBindingModel.kind, you might consider adding a comment explaining this or verifying whether validation is intentionally deferred.frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
52-60: Refactorwhen()usage to avoid BiomenoThenPropertyerrorsBiome is flagging the object‑literal
thenproperties here (lint/suspicious/noThenProperty). To keep the linter happy and stay within the Yup API, you can switch to the function‑stylewhencallback, which avoids defining athenproperty altogether while preserving behavior.One possible refactor:
- formData: yup.mixed().when('editorType', { - is: EditorType.Form, - then: (schema) => schema.concat(formDataSchema()), - }), + formData: yup.mixed().when('editorType', (editorType, schema) => + editorType === EditorType.Form ? schema.concat(formDataSchema()) : schema, + ), @@ - yamlData: yup.mixed().when('editorType', { - is: EditorType.YAML, - then: (schema) => - schema.concat(yup.string().required(i18n.t('shipwright-plugin~Required'))), - }), + yamlData: yup.mixed().when('editorType', (editorType, schema) => + editorType === EditorType.YAML + ? schema.concat(yup.string().required(i18n.t('shipwright-plugin~Required'))) + : schema, + ),This keeps the conditional logic the same while resolving the linter error.
Please verify against your Yup version that the
when('editorType', (value, schema) => ...)overload is supported exactly as used above before adopting this refactor.frontend/packages/dev-console/src/components/import/validation-schema.ts (1)
219-220: Make CPU/memory request/limit cross-field checks robust to nullsYou’ve made
cpu.request,cpu.limit,memory.request, andmemory.limitnullable, but the cross-field tests still callconvertToBaseValue(\${request}${requestUnit}`)even whenrequestcan benull/undefined. That relies onconvertToBaseValuehandling strings like'null'/'undefined'`, which is brittle.Consider short‑circuiting when either side is absent:
cpu: yup.object().shape({ request: yup .number() .nullable() .transform((request) => (_.isNaN(request) ? undefined : request)) .min(0, t('devconsole~Request must be greater than or equal to 0.')) .test({ test(request) { const { requestUnit, limit, limitUnit } = this.parent; - if (limit !== undefined && limit !== null) { + if (request != null && limit != null) { return ( convertToBaseValue(`${request}${requestUnit}`) <= convertToBaseValue(`${limit}${limitUnit}`) ); } return true; },limit: yup .number() .nullable() .transform((limit) => (_.isNaN(limit) ? undefined : limit)) .min(0, t('devconsole~Limit must be greater than or equal to 0.')) .test({ test(limit) { const { request, requestUnit, limitUnit } = this.parent; - if (limit !== undefined && limit !== null) { + if (limit != null && request != null) { return ( convertToBaseValue(`${limit}${limitUnit}`) >= convertToBaseValue(`${request}${requestUnit}`) ); } return true; },And similarly for
memory.request/memory.limit.This keeps the intended ordering constraints while avoiding surprises when only one side of the pair is set.
Also applies to: 225-226, 235-236, 239-240, 245-246, 259-260, 265-266, 279-280, 285-286
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (1)
17-24: Confirm whetherdockerfileshould be required whentype === 'dockerfile'For
sourceSchema:
- The
gitbranch correctly usesthen: (schema) => schema.shape({ git: { url, ref, dir } }).- The
dockerfilebranch is:dockerfile: yup.string().when('type', { is: 'dockerfile', then: (schema) => schema, }),
then: (schema) => schemais effectively a no‑op, sodockerfileremains an optional string even whentypeis'dockerfile'.If the intent is to require dockerfile content in that mode, consider:
dockerfile: yup.string().when('type', { is: 'dockerfile', - then: (schema) => schema, + then: (schema) => schema.required(i18n.t('devconsole~Required')), }),The image schema branches (
imageStreamTag,imageStreamImage,dockerImage) look correct with the new functionalthenstyle.Also applies to: 28-29, 38-45, 49-53
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
⛔ Files ignored due to path filters (1)
frontend/yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (28)
frontend/package.json(1 hunks)frontend/packages/dev-console/locales/en/devconsole.json(0 hunks)frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts(3 hunks)frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/hpa/validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx(2 hunks)frontend/packages/dev-console/src/components/import/validation-schema.ts(10 hunks)frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts(1 hunks)frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts(1 hunks)frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts(1 hunks)frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts(1 hunks)frontend/packages/integration-tests-cypress/views/details-page.ts(1 hunks)frontend/packages/integration-tests-cypress/views/secret.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts(1 hunks)frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts(2 hunks)frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx(1 hunks)frontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx(1 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts(3 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/__tests__/form-switcher-validation.spec.ts(5 hunks)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts(3 hunks)frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts(2 hunks)frontend/packages/shipwright-plugin/src/components/build-form/validation.ts(1 hunks)frontend/packages/vsphere-plugin/package.json(1 hunks)frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts(1 hunks)frontend/public/components/configmaps/configmap-utils.ts(1 hunks)
💤 Files with no reviewable changes (1)
- frontend/packages/dev-console/locales/en/devconsole.json
🚧 Files skipped from review as they are similar to previous changes (8)
- frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts
- frontend/packages/dev-console/src/components/project-access/tests/project-access-form-validation-utils.spec.ts
- frontend/packages/metal3-plugin/src/components/baremetal-hosts/add-baremetal-host/AddBareMetalHost.tsx
- frontend/package.json
- frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts
- frontend/packages/vsphere-plugin/package.json
- frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/tests/form-switcher-validation.spec.ts
- frontend/packages/integration-tests-cypress/views/secret.ts
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.tsfrontend/public/components/configmaps/configmap-utils.tsfrontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsxfrontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.tsfrontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsxfrontend/packages/dev-console/src/components/hpa/validation-utils.tsfrontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.tsfrontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.tsfrontend/packages/integration-tests-cypress/views/details-page.tsfrontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.tsfrontend/packages/dev-console/src/components/buildconfig/form-utils/validation.tsfrontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.tsfrontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.tsfrontend/packages/dev-console/src/components/import/validation-schema.tsfrontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.tsfrontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.tsfrontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.tsfrontend/packages/shipwright-plugin/src/components/build-form/validation.tsfrontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts
🧬 Code graph analysis (11)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/public/components/configmaps/configmap-utils.ts (1)
frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
formDataSchema(35-42)
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx (2)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
sinkTypeUriValidation(11-20)frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/dev-console/src/components/hpa/validation-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (4)
frontend/__mocks__/i18next.ts (1)
t(8-14)frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (1)
sinkTypeUriValidation(11-20)frontend/packages/knative-plugin/src/models.ts (2)
KafkaSinkModel(284-300)CamelKameletBindingModel(248-264)frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
projectNameValidationSchema(31-39)applicationNameValidationSchema(41-50)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (2)
frontend/__mocks__/i18next.ts (1)
t(8-14)frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
projectNameValidationSchema(31-39)applicationNameValidationSchema(41-50)
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts (5)
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (1)
validationSchema(85-106)frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts (1)
validationSchema(33-48)frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (1)
validationSchema(477-492)frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
validationSchema(44-66)frontend/public/components/configmaps/configmap-utils.ts (1)
validationSchema(198-219)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
frontend/__mocks__/i18next.ts (1)
t(8-14)frontend/public/components/utils/units.js (1)
value(225-225)
frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts (1)
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
projectNameValidationSchema(31-39)applicationNameValidationSchema(41-50)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (1)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/types.ts (1)
PipelineBuilderFormYamlValues(64-69)
🪛 Biome (2.1.2)
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 100-100: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/public/components/configmaps/configmap-utils.ts
[error] 208-208: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 212-212: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx
[error] 82-82: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/hpa/validation-utils.ts
[error] 12-12: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts
[error] 18-18: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 25-25: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 33-33: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 50-50: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 58-58: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts
[error] 14-14: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 22-22: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 29-29: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 38-38: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 49-49: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 74-74: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 89-89: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 104-104: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 113-113: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts
[error] 27-27: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 34-34: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 42-42: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 55-55: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 64-64: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 97-97: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 146-146: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 167-167: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 184-184: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts
[error] 17-17: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 28-28: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 38-38: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 49-49: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 53-53: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 95-95: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 99-99: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts
[error] 116-116: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 125-125: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 140-140: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts
[error] 16-16: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 45-45: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 56-56: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 63-63: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/import/validation-schema.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 80-80: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 188-188: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 301-301: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 317-317: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 328-328: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 340-340: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 375-375: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts
[error] 41-41: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts
[error] 15-15: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts
[error] 485-485: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/shipwright-plugin/src/components/build-form/validation.ts
[error] 54-54: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 58-58: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts
[error] 23-23: Do not add then to an object.
(lint/suspicious/noThenProperty)
🔇 Additional comments (25)
frontend/packages/dev-console/src/components/project-access/__tests__/project-access-form-data.ts (1)
6-9: Subject structure change is consistent and correctUpdating the first
projectAccessentry to use asubjectobject ({ name, kind }) matches the rest of this file’s mocks and the updated validation/tests, improving type and data-shape consistency. No issues from a maintainability or behavior standpoint.frontend/packages/webterminal-plugin/src/components/cloud-shell/setup/cloud-shell-setup-utils.ts (1)
23-29: LGTM: Yup 1.x migration correctly implemented.The functional
thencallback correctly receives the schema and augments it with.matches()and.required(). This preserves the original validation logic while conforming to Yup 1.x breaking changes.Note: The Biome lint warning on line 23 (
lint/suspicious/noThenProperty) is a false positive—Yup's.when()API legitimately accepts objects withisandthenproperties.frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx (1)
59-68: Status normalization looks sound; confirm'Success'as the default semanticThe normalization preserves any existing
statusobject (including error cases) and only fabricates a{ status: 'Success', metadata: {} }-style object whenstatus?.statusis missing, which is a reasonable way to guaranteeisi.status.statusis a string for Yup.Please just confirm that treating tags with a missing
statusfield as a'Success'state is aligned with the ImageStreamTag API semantics and any downstream logic that inspects this field.Also applies to: 77-77
frontend/packages/pipelines-plugin/src/components/repository/repository-form-utils.ts (3)
28-74: LGTM! Yup 1.x migration correctly applied.The migration from static
then:object shapes to functionalthen: (schema) => schema.shape({...})is correct. The previous issue regardingbitBucketUserNameRegexhas been resolved—line 52 now correctly validates Bitbucket usernames with underscores allowed.
76-110: LGTM! Consistent migration pattern.The Yup 1.x migration is correctly applied, and the validation logic is consistent with
repositoryValidationSchema. The use ofbitBucketUserNameRegexat line 86 is correct.
112-119: LGTM! Correct use of schema.concat().The migration to
schema.concat(pipelinesAccessTokenValidationSchema(t))correctly merges the schemas, ensuring the base schema is augmented rather than replaced.frontend/packages/knative-plugin/src/components/add/brokers/broker-validation-utils.ts (1)
15-20: LGTM! Correct Yup 1.x migration pattern.The functional
thencallback correctly extends the schema for Form editor validation. The static analysis warning is a false positive—thenhere is part of Yup's conditional validation API (.when()), not a Promise method.frontend/packages/knative-plugin/src/components/sink-source/SinkSource.tsx (1)
82-82: LGTM! Correct schema composition with concat.The functional
thencallback properly merges the URI validation schema usingconcat(). This follows the Yup 1.x pattern for extending schemas conditionally. The Biome warning is a false positive.frontend/packages/knative-plugin/src/components/add/eventSink-validation-utils.ts (1)
18-21: LGTM! Consistent Yup 1.x migration.All conditional validations correctly use functional
thencallbacks with appropriate schema extensions viashape()andconcat(). The patterns align with the project-wide Yup upgrade strategy.Also applies to: 25-25, 33-46, 58-65
frontend/packages/knative-plugin/src/components/add/eventSource-validation-utils.ts (4)
27-30: LGTM! Correct sink validation migration.Both Resource and Uri sink type validations properly use functional
thencallbacks—Resource extends with required name validation, Uri concatenates the URI validation schema.Also applies to: 34-34
42-51: LGTM! Comprehensive event source validations correctly migrated.All event source types (PingSource, SinkBinding, ApiServerSource, KafkaSource, ContainerSource) now use functional
thencallbacks with appropriate nested schema structures. The nested conditional validation in SinkBinding (lines 62-64) correctly makesnamerequired whenselector.matchLabelsis absent.Also applies to: 55-76, 80-93, 97-142, 146-159
167-174: LGTM! Top-level validation schemas properly updated.Both
eventSourceValidationSchemaandaddChannelValidationSchemacorrectly apply functionalthencallbacks for Form editor validation, maintaining consistency with the broader Yup 1.x migration.Also applies to: 184-191
1-194: Note: Static analysis warnings are false positives.Biome's "Do not add then to an object" warnings throughout this file are false positives. The
thenproperty is part of Yup's conditional validation API (used with.when()), not the Promise.then()method. Consider updating your Biome configuration to exclude this rule for Yup validation files or add an exception for this pattern.frontend/packages/helm-plugin/src/components/forms/HelmChartRepository/helmchartrepository-validation-utils.ts (1)
33-47: Async wrapper for nested Yup validation looks correctThe async
testfunction, the awaitedformYamlDefinition.validate(..., { abortEarly: false }), and returningtrueon success are all consistent with Yup 1.x’s async test behavior, and thewhen('editorType', { is: EditorType.Form, then: (schema) => schema.concat(createHelmChartRepositoryValidationSchema(t)) })composition correctly applies the repository schema only for the form editor path. I don’t see issues here from a correctness or maintainability standpoint.If not already done, please re-run the relevant validation tests for the Helm chart repository flow after the Yup 1.x upgrade to confirm there are no regressions in editorType/Form vs YAML behavior.
frontend/packages/shipwright-plugin/src/components/build-form/validation.ts (1)
44-65: Async validation wrapper matches Yup 1.x behaviorMaking the
testcallbackasync, awaitingformYamlDefinition.validate(values, { abortEarly: false }), and returningtrueon success is a correct adaptation to Yup 1.x’s promise‑basedvalidate()— all failures will surface via the thrownValidationError, so no extra branching is needed here.Please double‑check against the Yup 1.x docs that you don’t need to forward any additional options (like
context) from the outer schema into this innervalidate()call for your use cases.frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
16-41: Yup 1.xwhen().thenmigration here looks correctThe switch to functional
then: (schema) => schema.shape({ … })fordata,httpGet,tcpSocket, andexecpreserves the existing constraints and matches the pattern used elsewhere in the PR. The BiomenoThenPropertywarnings are false positives in this context, sincethenis part of Yup’swhenconfig object.Also applies to: 43-52, 54-59, 61-66
frontend/packages/dev-console/src/components/deployments/utils/deployment-validation-utils.ts (1)
116-129: Deployment form Yup migration is consistent and preserves behaviorUsing functional
thencallbacks forimageStreamandisiand the asyncvalidationSchemathat awaitsformYamlDefinition.validate(...)aligns with the pattern used in other validation utilities in this PR. The composed schema still correctly gates form validation oneditorTypeandfromImageStreamTagwithout introducing new edge cases.Also applies to: 134-146
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
48-49: Conditional required for application name looks correctThe
then: (schema) => schema.required('Required')branch cleanly restricts the required constraint to theCREATE_APPLICATION_KEYcase without changing behavior for other keys.
301-305: Yupwhen().thenupdates for image/git/docker/devfile/pipeline/ISI schemas look goodAll of these branches correctly adopt the functional
then: (schema) => schema.shape(...)/schema.required(...)pattern:
imageValidationSchemanow conditionally requiresselectedandtagwhenbuild.strategy === 'Source'.gitValidationSchemaonly requirestypewhenshowGitTypeis true, preserving previous behavior.dockerValidationSchemaanddevfileValidationSchemagate their required fields on the selected build strategy.isiValidationSchema’s nestedstatus.statusrequirement and the pipeline template’stemplateSelectedrequirement are cleanly expressed via conditionalshapecalls.These migrations are consistent with the broader Yup 1.x refactor and don’t introduce new edge cases.
Also applies to: 317-320, 328-334, 340-349, 365-366, 375-378
frontend/packages/dev-console/src/components/buildconfig/form-utils/validation.ts (1)
87-88: Async editorType-gated validation schema is consistent with the rest of the codebaseThe async
validationSchematest that builds a localformYamlDefinition, gatesformData/yamlDataoneditorType, andawaitsvalidate(values, { abortEarly: false })before returningtruematches the pattern used in other updated validation utilities. This is an appropriate way to integrate Yup’s async behavior with the surrounding form logic.Also applies to: 95-96, 99-100, 103-104
frontend/packages/pipelines-plugin/src/components/pipelines/pipeline-builder/validation-utils.ts (2)
279-283: Explicit boolean coercion in tests looks correctUsing
!!resourceValueand!!workspaceValuemakes the custom tests return explicit booleans instead of relying on string truthiness, which is safer and clearer for the validator. No functional issues here.Also applies to: 390-395
477-491: Async wrapper and schema composition pattern confirmed as Yup v1 best practiceThe async
.test()method withawait‑edformYamlDefinition.validate(formValues, { abortEarly: false })correctly delegates field validation (including theeditorType‑driven.whenlogic) to the inner schema while preserving aggregated error reporting. The.when()withthen: (schema) => schema.concat(pipelineBuilderFormSchema(formValues))follows Yup v1's documented pattern for composing schemas with additional constraints.One operational consideration: generic linters (e.g., Biome) may flag the
thenproperty within.whenconfiguration objects as suspicious, even though this is the intended Yup API. If adopting such tooling, consider a targeted suppression for these specific.whenconfigurations rather than modifying this code.frontend/packages/pipelines-plugin/src/components/pipelines/modals/common/validation-utils.ts (2)
69-130: Volumewhen(type)schemas verified as valid Yup patternYup's conditions are additive, allowing multiple
.when()calls to be chained on the same field, with eachthenbranch applied only when its specificispredicate matches. ThevolumeTypeSchemaimplementation correctly chains multiple.when('type', { is, then })clauses to conditionally shape the schema for eachVolumeTypesvariant, with the required fields for Secret, ConfigMap, PVC, and VolumeClaimTemplate clearly expressed.
7-55: Yupwhenrefactor for resource params/secrets and form resources is correctYup 1.x officially supports using
.when('field', { is, then: (schema) => schema.shape(...) })to conditionally extend object schemas based on sibling fields. The migration correctly uses this pattern to extend base object schemas rather than replace them, preserving thetypediscriminator while conditionally tightening validation when the correspondingPipelineResourceTypeis chosen.frontend/public/components/configmaps/configmap-utils.ts (1)
198-218: Async wrapper around nested Yup validation looks correctUsing an
asynctest, constructingformYamlDefinition, andawait‑ingvalidate(values, { abortEarly: false })before returningtrueis a correct pattern for Yup 1.x and keeps all actual error reporting inside the inner schema.
| formData: yup.mixed().when('editorType', { | ||
| is: EditorType.Form, | ||
| then: formDataSchema(values), | ||
| then: (schema) => schema.concat(formDataSchema(values)), | ||
| }), | ||
| yamlData: yup.mixed().when('editorType', { | ||
| is: EditorType.YAML, | ||
| then: yup.string().required(i18next.t('public~Required')), | ||
| then: (schema) => schema.concat(yup.string().required(i18next.t('public~Required'))), | ||
| }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Biome noThenProperty errors: prefer callback-form when instead of { is, then }
Biome flags the then properties here as errors, which will cause lint failures even though the Yup usage is valid. You can avoid this by switching to the callback form of when, keeping behavior the same while removing the then property:
- formData: yup.mixed().when('editorType', {
- is: EditorType.Form,
- then: (schema) => schema.concat(formDataSchema(values)),
- }),
- yamlData: yup.mixed().when('editorType', {
- is: EditorType.YAML,
- then: (schema) => schema.concat(yup.string().required(i18next.t('public~Required'))),
- }),
+ formData: yup.mixed().when('editorType', (editorType, schema) =>
+ editorType === EditorType.Form ? schema.concat(formDataSchema(values)) : schema,
+ ),
+ yamlData: yup.mixed().when('editorType', (editorType, schema) =>
+ editorType === EditorType.YAML
+ ? schema.concat(yup.string().required(i18next.t('public~Required')))
+ : schema,
+ ),Please verify this matches your Yup version’s when signature and, if adopted, consider applying the same pattern wherever Biome reports noThenProperty for Yup when.
I'll verify this review comment by examining the codebase, checking the Yup version, and confirming the Biome rule and syntax validity.
🏁 Script executed:
#!/bin/bash
# 1. Check the actual file content at the specified lines
echo "=== File content check ==="
cat frontend/public/components/configmaps/configmap-utils.ts | sed -n '206,213p'
# 2. Find package.json and check Yup version
echo -e "\n=== Yup version ==="
if [ -f "package.json" ]; then
jq '.dependencies.yup, .devDependencies.yup' package.json
else
find . -name "package.json" -type f | head -5 | xargs -I {} sh -c 'echo "File: {}"; jq ".dependencies.yup, .devDependencies.yup" {} 2>/dev/null'
fi
# 3. Check for Biome configuration
echo -e "\n=== Biome configuration ==="
if [ -f "biome.json" ]; then
cat biome.json | head -100
elif [ -f ".biome.json" ]; then
cat .biome.json | head -100
elif [ -f "biome.jsonc" ]; then
cat biome.jsonc | head -100
else
echo "No biome config file found in root"
fi
# 4. Search for other instances of when with then property
echo -e "\n=== Other instances of .when with then property ==="
rg '\.when\s*\(\s*["\']' frontend/public/components/configmaps/configmap-utils.ts -A 3 -B 1Length of output: 2651
I need to search for the Yup version and verify the Biome rule. Let me gather this information:
🏁 Script executed:
#!/bin/bash
# 1. Search for Yup in lock files
echo "=== Searching for Yup in lock files ==="
if [ -f "package-lock.json" ]; then
jq '.packages[] | select(.name == "yup") | {name, version}' package-lock.json 2>/dev/null | head -20
elif [ -f "yarn.lock" ]; then
grep -A 3 '"yup@' yarn.lock | head -20
elif [ -f "pnpm-lock.yaml" ]; then
grep -A 3 "yup:" pnpm-lock.yaml | head -20
fi
# 2. Check root package.json more carefully for Yup
echo -e "\n=== Root package.json dependencies ==="
jq '.dependencies | to_entries[] | select(.key == "yup" or .key | contains("yup"))' package.json 2>/dev/null || echo "Not in dependencies"
jq '.devDependencies | to_entries[] | select(.key == "yup" or .key | contains("yup"))' package.json 2>/dev/null || echo "Not in devDependencies"
# 3. Search for other .when( patterns with is/then (fixed ripgrep)
echo -e "\n=== Search for other .when() with then/is properties ==="
rg "\.when\s*\(" frontend/public/components/configmaps/configmap-utils.ts -A 4 -B 1
# 4. Check if there are imports of yup in the file to understand usage
echo -e "\n=== Yup imports in the file ==="
head -30 frontend/public/components/configmaps/configmap-utils.ts | grep -i "yup\|import"Length of output: 1038
🏁 Script executed:
#!/bin/bash
# Search for Yup version in frontend workspace packages
echo "=== Searching for Yup in frontend packages ==="
find frontend/packages -name "package.json" -type f | xargs grep -l '"yup"' 2>/dev/null | while read f; do
echo "File: $f"
jq '.dependencies.yup, .devDependencies.yup, .peerDependencies.yup' "$f" 2>/dev/null
done
# Also check if there's a pnpm workspace or yarn workspace lock file with Yup info
echo -e "\n=== Checking pnpm-lock for Yup ==="
if [ -f "pnpm-lock.yaml" ]; then
grep -A 5 "^ yup:" pnpm-lock.yaml | head -20
fiLength of output: 153
🌐 Web query:
Biome linter noThenProperty rule Yup validation
💡 Result:
Short answer — Biome’s suspicious/noThenProperty rule flags any object/class/property named "then" because creating thenable objects can unexpectedly interact with await/dynamic import. That can trigger when you write Yup conditional configs like .when('x', { is: ..., then: s => s.min(1), otherwise: ... }) since it uses an object property named then. See Biome docs for the rule and Yup docs for when(). [1][2]
What to do
- Prefer the function form of when (callback) to avoid an object with a top-level then property:
.when('x', ([x], schema) => x ? schema.min(1) : schema) - Or pass a builder function for then/otherwise (Yup supports then: schema => schema...), which still creates a property but is often written as a function form above.
- If you must use the object form, silence the rule locally:
// biome-disable-next-line suspicious/noThenProperty
.when('x', { is: true, then: s => s.min(1), otherwise: s => s }) - Alternatively rename the property where possible (not applicable to Yup API).
References
- Biome noThenProperty rule docs. [1]
- Yup Schema.when() docs (shows is/then/otherwise usage and builder-function forms). [2]
Sources
[1] Biome — noThenProperty rule.
[2] Yup — Schema.when / API documentation.
🌐 Web query:
Yup 1.7.1 when callback form signature
💡 Result:
Signature (Yup v1.7.1)
Schema.when(keys: string | string[], builder: object | (values: any[], schema) => Schema): Schema. [1][2]
Notes/examples
- The callback receives an array of dependent values and the current schema, e.g. .when('isWorking', ([isWorking], schema) => isWorking ? schema.required() : schema). Use array destructuring to get a single value. [1][2]
Fix the suggested code snippet to use proper array destructuring for the Yup 1.7.1 callback form
The review correctly identifies the Biome noThenProperty issue and suggests the callback form, which is valid. However, the provided code has a critical syntax error: the callback receives values as an array and must use destructuring per Yup 1.7.1's signature when(keys, (values, schema) => Schema).
Correct implementation:
- formData: yup.mixed().when('editorType', {
- is: EditorType.Form,
- then: (schema) => schema.concat(formDataSchema(values)),
- }),
- yamlData: yup.mixed().when('editorType', {
- is: EditorType.YAML,
- then: (schema) => schema.concat(yup.string().required(i18next.t('public~Required'))),
- }),
+ formData: yup.mixed().when('editorType', ([editorType], schema) =>
+ editorType === EditorType.Form ? schema.concat(formDataSchema(values)) : schema,
+ ),
+ yamlData: yup.mixed().when('editorType', ([editorType], schema) =>
+ editorType === EditorType.YAML
+ ? schema.concat(yup.string().required(i18next.t('public~Required')))
+ : schema,
+ ),Note the [editorType] array destructuring—without it, the code will fail at runtime.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| formData: yup.mixed().when('editorType', { | |
| is: EditorType.Form, | |
| then: formDataSchema(values), | |
| then: (schema) => schema.concat(formDataSchema(values)), | |
| }), | |
| yamlData: yup.mixed().when('editorType', { | |
| is: EditorType.YAML, | |
| then: yup.string().required(i18next.t('public~Required')), | |
| then: (schema) => schema.concat(yup.string().required(i18next.t('public~Required'))), | |
| }), | |
| formData: yup.mixed().when('editorType', ([editorType], schema) => | |
| editorType === EditorType.Form ? schema.concat(formDataSchema(values)) : schema, | |
| ), | |
| yamlData: yup.mixed().when('editorType', ([editorType], schema) => | |
| editorType === EditorType.YAML | |
| ? schema.concat(yup.string().required(i18next.t('public~Required'))) | |
| : schema, | |
| ), |
🧰 Tools
🪛 Biome (2.1.2)
[error] 208-208: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 212-212: Do not add then to an object.
(lint/suspicious/noThenProperty)
🤖 Prompt for AI Agents
In frontend/public/components/configmaps/configmap-utils.ts around lines 206 to
213, the Yup when callback is using the single-argument form but Yup 1.7.1
provides values as an array; change both when usages to the array-destructuring
callback form: use when(['editorType'], ([editorType], schema) => ...) and
return schema.concat(...) for each case (for EditorType.Form call
formDataSchema(values) with the correct destructured value, for EditorType.YAML
concat yup.string().required(...)). Ensure the first parameter to when is an
array ['editorType'] and the callback signature is ([editorType], schema) =>
Schema so runtime errors are avoided.
|
It seems like As the test @krishagarwal278 Do you wanna try to locally run this cypress test and to see whether this failure is caused by the PR change? |
29f6b0d to
7a62519
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
frontend/packages/dev-console/src/components/import/validation-schema.ts (1)
151-160: [Duplicate] Fix edge cases in autoscale window and domainMapping validationTwo edge-case issues remain unaddressed:
- autoscalewindow validation (Lines 151-160): Using
if (autoscalewindow)treats0as falsy, so a value of0seconds silently bypasses the6–3600range check. Explicitly check fornull/undefined:.test({ test(autoscalewindow) { - if (autoscalewindow) { + if (autoscalewindow !== null && autoscalewindow !== undefined) { const { autoscalewindowUnit } = this.parent; const value = convertToSec(autoscalewindow, autoscalewindowUnit); return value >= 6 && value <= 3600; } return true; },
- domainname-has-segments test (Lines 173-178):
domainNamecan beundefinedor empty (withexcludeEmptyString: trueon the precedingmatches), causingdomainName.split('.')to throw. Guard against falsy values:.test( 'domainname-has-segements', t('devconsole~Domain name must consist of at least two segments separated by dots.'), - function (domainName: string) { + function (domainName?: string | null) { + if (!domainName) { + return true; + } return domainName.split('.').length >= 2; }, ),Also applies to: 173-178
🧹 Nitpick comments (6)
frontend/packages/integration-tests-cypress/views/details-page.ts (1)
2-5: Redundant element query on line 4.Line 4 re-queries
[data-test="page-heading"]immediately after line 3 already retrieved and verified it. Cypress retains the subject from the previous command, so the second query is unnecessary.Apply this diff to chain commands efficiently:
titleShouldContain: (title: string) => { - cy.get('[data-test="page-heading"]', { timeout: 30000 }).should('be.visible'); - return cy.get('[data-test="page-heading"]').contains(title, { timeout: 30000 }); + return cy.get('[data-test="page-heading"]', { timeout: 30000 }) + .should('be.visible') + .contains(title); },Note: The 30-second timeout is quite long. Verify this is intentional for slow page loads in your test environment.
frontend/packages/dev-console/integration-tests/support/pages/add-flow/container-image-page.ts (1)
41-44: Good async wait; consider optionally guarding confirm button enablement tooWaiting for the URL input to be visible and not disabled before typing is a solid way to reduce flakiness with async Yup-driven state and modal rendering.
If you still see intermittent failures around the final click, consider also asserting that the confirm button is enabled before clicking (e.g.,
cy.get(...confirmButton).should('not.be.disabled').click()), so both the field and the action control are guaranteed ready. This would be a small extra hardening, not a blocker.frontend/packages/integration-tests-cypress/views/secret.ts (1)
35-42: Replace arbitrary wait and forced click with deterministic conditions.The
cy.wait(500)introduces test flakiness (too short on slow systems, unnecessarily slow on fast ones), and{ force: true }bypasses Cypress's actionability checks, potentially masking real UI issues.Consider replacing with a deterministic pattern:
clickRevealValues: () => { - // Wait for the button to be stable (not re-rendering) - cy.byTestID('reveal-values', { timeout: 30000 }).should('be.visible'); - // Add a small delay to ensure page is stable after any re-renders - // eslint-disable-next-line cypress/no-unnecessary-waiting - cy.wait(500); - cy.byTestID('reveal-values').click({ force: true }); + cy.byTestID('reveal-values', { timeout: 30000 }) + .should('be.visible') + .should('not.be.disabled') + .click(); },If re-renders are still causing issues, consider waiting for the element to be stable using
.should('have.attr', 'data-test', 'reveal-values')or a similar condition that verifies the element's DOM state rather than using arbitrary timeouts.frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
16-16: BiomenoThenPropertylooks like a false positive for Yup config objectsStatic analysis is flagging the
thenproperties as suspicious, but these keys are required by Yup’s.when()API and the objects are not being treated as general-purpose thenables. If Biome’slint/suspicious/noThenPropertyrule is enforced in this repo, consider adding a targeted suppression (e.g.,// biome-ignore lint/suspicious/noThenProperty) near thesewhenconfigs or disabling the rule for this file/module to avoid noisy false positives while keeping the valid Yup usage.Also applies to: 45-45, 57-57, 65-65
frontend/packages/dev-console/src/components/import/validation-schema.ts (1)
238-239: Consider consistent unit field handling across CPU and memory.CPU unit fields use
.string().ensure()(Lines 238-239) while memory unit fields use plain.string()(Lines 278, 297). This difference means CPU units default to empty string when undefined, while memory units remain undefined.If this is intentional, consider documenting why; otherwise, align both to use
.ensure()for consistency:- requestUnit: yup.string(), + requestUnit: yup.string().ensure(),- limitUnit: yup.string(), + limitUnit: yup.string().ensure(),Also applies to: 278-297
frontend/packages/topology/integration-tests/support/pages/topology/topology-page.ts (1)
80-81: Consider chaining the element query to avoid redundant selection.The same element is selected twice in succession. You could chain the
.then()callback to the first query to avoid the redundant selector.Apply this diff to refactor:
- // Wait for topology page to load completely - increased timeout for yup async validation - cy.get('[class*="odc-topology"]', { timeout: 60000 }).should('be.visible'); - cy.get('[class*="odc-topology"]').then(($el) => { + // Wait for topology page to load completely - increased timeout for yup async validation + cy.get('[class*="odc-topology"]', { timeout: 60000 }).should('be.visible').then(($el) => { if ($el.find('[data-test="no-resources-found"]').length) { throw new Error(`No workload has been created till now.`); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (10)
frontend/packages/dev-console/integration-tests/support/pages/add-flow/container-image-page.ts(1 hunks)frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts(1 hunks)frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx(2 hunks)frontend/packages/dev-console/src/components/import/validation-schema.ts(10 hunks)frontend/packages/integration-tests-cypress/support/project.ts(1 hunks)frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts(3 hunks)frontend/packages/integration-tests-cypress/views/details-page.ts(1 hunks)frontend/packages/integration-tests-cypress/views/secret.ts(1 hunks)frontend/packages/topology/integration-tests/support/pages/topology/topology-page.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/packages/integration-tests-cypress/tests/crud/secrets/image-pull.cy.ts
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsxfrontend/packages/integration-tests-cypress/support/project.tsfrontend/packages/integration-tests-cypress/views/secret.tsfrontend/packages/topology/integration-tests/support/pages/topology/topology-page.tsfrontend/packages/dev-console/src/components/import/validation-schema.tsfrontend/packages/dev-console/integration-tests/support/pages/add-flow/container-image-page.tsfrontend/packages/dev-console/src/components/import/deployImage-validation-utils.tsfrontend/packages/integration-tests-cypress/views/details-page.tsfrontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts
🧬 Code graph analysis (3)
frontend/packages/dev-console/src/components/import/validation-schema.ts (2)
frontend/__mocks__/i18next.ts (1)
t(8-14)frontend/public/components/utils/units.js (1)
value(225-225)
frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts (2)
frontend/packages/dev-console/src/components/import/validation-schema.ts (1)
isiValidationSchema(366-374)frontend/__mocks__/i18next.ts (1)
t(8-14)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
frontend/__mocks__/i18next.ts (1)
t(8-14)
🪛 Biome (2.1.2)
frontend/packages/dev-console/src/components/import/validation-schema.ts
[error] 48-48: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 81-81: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 190-190: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 304-304: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 321-321: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 333-333: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 346-346: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 382-382: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts
[error] 23-23: Do not add then to an object.
(lint/suspicious/noThenProperty)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts
[error] 16-16: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 45-45: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 57-57: Do not add then to an object.
(lint/suspicious/noThenProperty)
[error] 65-65: Do not add then to an object.
(lint/suspicious/noThenProperty)
🔇 Additional comments (4)
frontend/packages/dev-console/src/components/health-checks/health-checks-probe-validation-utils.ts (1)
16-72: Yup 1.xwhen/then/otherwisemigration preserves validation behaviorThe new functional
thencallbacks (schema => schema.shape({ ... })) and identityotherwisebranches fordata,httpGet,tcpSocket, andexeccleanly layer additional constraints only whenshowForm/requestTypematch, and otherwise leave the base object schema untouched. This is consistent with Yup’s 1.xwhenpatterns and should preserve the previous validation semantics for health checks.frontend/packages/dev-console/src/components/import/image-search/ImageStreamTagDropdown.tsx (1)
59-77: I encountered a repository cloning issue that prevents me from directly examining the codebase. However, based on the review comment structure and the verification challenges, I can provide you with a rewritten review comment that acknowledges the verification needs:
Verify the hardcoded 'Success' default and schema compatibility with the updated Yup validation.
The normalization logic defaults
status.statusto'Success'when the nested property is absent. This requires verification that:
- The normalized structure matches the Yup 1.7.1 validation schema for
isi.status- The
'Success'default is semantically correct for all cases wherestatus.statusis missing- The error path (lines 100-104) which sets
status: ''is compatible with the same validation schemaExamine the validation schema for the import form and confirm whether the hardcoded default accurately represents ImageStreamTag behavior when status is incomplete or missing.
frontend/packages/dev-console/src/components/import/validation-schema.ts (1)
48-48: BiomenoThenPropertyerrors are false positives.The Biome linter flags all callback-style
then: (schema) => ...usages as suspicious, but this is the correct and recommended Yup 1.x API pattern for conditional schema composition. The rule is intended to catch plain objects withthenproperties that might be confused with Promises, but doesn't distinguish callback functions.You can safely suppress these warnings or update the Biome configuration to allow this pattern.
Also applies to: 81-81, 190-190, 304-304, 321-321, 333-333, 346-346, 382-382
frontend/packages/dev-console/src/components/import/deployImage-validation-utils.ts (1)
21-25: BiomenoThenPropertyerror is a false positive.The object-form
whenwith callback-stylethen: (schema) => schema.concat(...)is valid Yup 1.x API. Biome's linter doesn't distinguish between thenable objects and Yup's conditional schema callbacks. The pattern here correctly appliesisiValidationSchema(t)only whenregistry === 'internal'.You can suppress this warning or align with the Biome configuration used for similar patterns throughout the codebase.
| Cypress.Commands.add('deleteProjectWithCLI', (name: string, timeout?: number) => { | ||
| cy.exec(`oc delete project ${name}`, { timeout }); | ||
| // First try normal delete, if it times out, force delete | ||
| cy.exec(`oc delete project ${name} --wait=false`, { | ||
| timeout: timeout || 60000, | ||
| failOnNonZeroExit: false, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Script executed:
#!/bin/bash
# First, let's read the file to see the actual current state
cat -n frontend/packages/integration-tests-cypress/support/project.ts | head -80Repository: openshift/console
<shell_result>
Repository: openshift/console
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository openshift/console: Clone operation failed
</shell_result>
Script executed:
#!/bin/bash
# Check the git history to see what changed in this file
git log --oneline -20 -- frontend/packages/integration-tests-cypress/support/project.tsRepository: openshift/console
<shell_result>
Repository: openshift/console
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository openshift/console: Clone operation failed
</shell_result>
Script executed:
#!/bin/bash
# Get the actual diff for this specific function to see what changed
git diff HEAD~1 frontend/packages/integration-tests-cypress/support/project.ts | head -100Repository: openshift/console
<shell_result>
Repository: openshift/console
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository openshift/console: Clone operation failed
</shell_result>
Script executed:
#!/bin/bash
# Search for other uses of deleteProjectWithCLI in tests
rg -n "deleteProjectWithCLI" --type tsRepository: openshift/console
<shell_result>
Repository: openshift/console
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository openshift/console: Clone operation failed
</shell_result>
The shell scripts encountered a repository cloning failure. Let me analyze the review comment using the provided code snippet directly.
Based on the code provided in the review comment, I can verify the concerns:
Code snippet (lines 54-60):
Cypress.Commands.add('deleteProjectWithCLI', (name: string, timeout?: number) => {
// First try normal delete, if it times out, force delete
cy.exec(`oc delete project ${name} --wait=false`, {
timeout: timeout || 60000,
failOnNonZeroExit: false,
});
});Analysis of the review comment's claims:
-
✓ Misleading comment: The comment claims "First try normal delete, if it times out, force delete" but there is only ONE
cy.exec()call with no conditional logic or second attempt. -
✓ No fallback logic: There's no
.then()handler, no error handling, or second delete attempt. The function returns immediately after the first call. -
✓ Silent failures:
failOnNonZeroExit: falsesuppresses errors without any error handling code. -
✓
--wait=falsebehavior: This flag tells OpenShift to return immediately without waiting for deletion. The review correctly notes this doesn't mean "force delete." -
✓ Race condition risk: Without waiting for deletion, subsequent tests could attempt to create projects with the same name before deletion completes.
The review comment's analysis is accurate. The implementation does not match its comment, creates silent failures, and lacks the claimed fallback behavior. The provided diff suggestion shows what proper fallback logic should look like (checking result code and performing force delete on failure).
Misleading comment and no actual fallback implementation.
The comment claims "First try normal delete, if it times out, force delete," but the code contains only a single delete operation with no fallback logic:
failOnNonZeroExit: falsesilences errors without handling them--wait=falsereturns immediately without waiting for deletion, creating race conditions for tests that reuse project names- No conditional logic or retry mechanism exists despite what the comment suggests
Issues:
- Silent failures mask deletion problems
- Race conditions if subsequent tests use the same project name
- Comment contradicts implementation
Apply the suggested diff to implement actual fallback behavior, or update the comment to reflect the actual non-waiting approach.
🤖 Prompt for AI Agents
In frontend/packages/integration-tests-cypress/support/project.ts around lines
54-60 the function comment promises "First try normal delete, if it times out,
force delete" but the implementation only issues a single non-blocking
cy.exec(`oc delete ... --wait=false`) with failOnNonZeroExit:false, causing
silent failures and race conditions; change the command flow to actually attempt
a blocking delete first (invoke oc delete without --wait=false or with waiting
behavior), attach .then/.catch to inspect the result/exit code or detect a
timeout, and if the first attempt fails or times out invoke a second exec that
force-deletes the project, poll/wait until the project is gone before returning,
and add logging so errors are not silently suppressed (ensure the returned
Cypress command chain reflects success/failure correctly).
| // Wait for topology page to load completely - increased timeout for yup async validation | ||
| cy.get('[class*="odc-topology"]', { timeout: 60000 }).should('be.visible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Script executed:
#!/bin/bash
# Search for form validation and Yup usage in topology components
echo "=== Searching for form validation/Yup usage in topology ==="
rg -n --type=ts --type=tsx -C3 'yup|validation|validate' frontend/packages/topology/src/ | head -80
echo ""
echo "=== Looking for odc-topology class usage ==="
rg -n 'odc-topology' frontend/packages/topology/ | head -30
echo ""
echo "=== Checking if topology page has forms ==="
rg -n --type=tsx '<Form' frontend/packages/topology/src/components/ | head -20Repository: openshift/console
<shell_result>
Repository: openshift/console
Script execution failed with unrecoverable error: [CAPABILITY:RUN_SHELL_SCRIPT] Failed to clone repository openshift/console: Clone operation failed
</shell_result>
Yup 0.27.0 to 1.7.1 upgrade breaking changes async validation performance
<web_search_result>
Short answer: upgrading from yup 0.27.0 → 1.7.1 can expose breaking changes that make validations behave more often as async (and therefore slower) — mainly because the v1 line introduced API/implementation changes that make tests/validation Promise‑based, changed how required/tests are represented, and refactored internal flows (more async checks / microtask scheduling). Those changes can produce measurable performance regressions for forms that run many validations per keystroke. See the v1 release notes and current API docs. [1][2]
What changed (high level)
- v1 refactor / breaking changes: internal API and test handling were reworked as part of the v1 series (breaking changes, different required/test semantics). This made more validation paths use Promise/async flows. [1]
- Public API clarifications: many Schema methods are explicitly async (validate, isValid, validateAt) and docs note caveats around async tests and validateSync. If any test returns a Promise, sync variants fall back to async. That can convert previously sync validations into async ones. [2]
- Small implementation/packaging changes in v1 (bundling, internals) that affect how code is executed and parsed — can change runtime cost. [1]
Why that hurts performance
- Async validation means many Promise microtasks and more event‑loop churn for each field/value, especially when validating nested schemas or many fields on each input event.
- If you relied on validateSync or purely synchronous custom tests in 0.27 that are now treated as async (or you added Promise‑returning tests), the cost per validation rises and UI latency increases.
Quick ways to diagnose and mitigate
- Confirm which validations are async: audit custom tests/when callbacks — any that return a Promise (or call async functions) force async validation. Use validateSync/isValidSync only when you are certain no async tests run. [2]
- Minimize async tests: convert server/IO checks to debounced calls outside schema validation (e.g., onBlur or separate availability checks) so schema validation stays synchronous.
- Batch/ debounce validations: debounce onChange validation or run heavy async checks only on submit or blur.
- Use validateSync for fast local checks and run async checks separately.
- Profile: measure validation time in the app (console.time) to find hot spots (large arrays, deep schemas, many .test calls).
- Consider a faster schema library for hot paths (e.g., Zod) if you need synchronous, high‑throughput validation.
- Upgrade to the absolute latest 1.x (1.7.1 was current at Snyk/npm listing) — check release notes for any perf fixes between 1.0→1.7.1. [3][1]
References
- Yup releases / v1 notes (breaking changes and rationale). [1]
- Yup API docs (validate/validateSync, isValid, and async‑test caveats). [2]
- Package/version info (latest 1.7.1 listed). [3]
If you want, I can:
- scan your code (schema + custom tests) and point out which tests will force async validation, or
- produce a small repro to measure the perf delta and show mitigations. Which would you prefer?
</web_search_result>
Yup async validation timeout performance impact
<web_search_result>
Short answer: Using async tests in Yup forces validation to run asynchronously (returns a Promise), which adds an extra event-loop turn and can noticeably hurt UX when invoked frequently (per‑keystroke / onChange) or when those async tests perform network/IO. Mitigations: avoid async tests where possible, debounce/throttle validation, validate on blur/submit instead of onChange, reuse/compile schema once, offload heavy checks to a worker, or switch to a faster validator for hot paths. [1][2][3][4]
Key points and actionable fixes
- Why it hurts: any test that returns a Promise makes the whole schema validation async (no validateSync) — this inserts microtask scheduling and prevents synchronous short‑circuiting, so frequent calls add latency. Also async tests often do network calls which are the main cost. [2][4]
- UX symptoms: input lag when validating onChange, slow form responsiveness with many fields. Numerous reports show per‑keystroke async checks are wasteful and should be debounced. [6][7]
- Quick fixes:
- Remove async tests if they’re not needed; use synchronous checks where possible. [2]
- Debounce async validations (client-side) or only run them onBlur/submit. [6][7]
- Reuse the same schema instance (avoid rebuilding on every render). [4]
- Offload expensive checks (network/DB) to a background worker or perform them separately from field-level validation.
- If raw validation speed is critical, consider a faster validator (AJV/compiled JSON‑Schema, Zod/TypeBox) for hot paths. Benchmarks and comparisons show compiled/JSON‑schema validators outperform Yup in raw speed. [1][5]
References
- Yup docs: async tests, validate vs validateSync behavior. [2]
- Yup GitHub and implementation notes on async tests and behavior. [4]
- React‑Hook‑Form / RHF issue recommending debouncing async field validators. [6]
- StackOverflow reports of input lag caused by Yup validation. [7]
- Performance comparisons / writeups (AJV, Zod vs Yup). [1][5]
</web_search_result>
openshift console topology page Yup upgrade 60 second timeout PR
<web_search_result>
I’m not sure what you mean — do you want the PR link, its status, or a summary of the change? Please clarify.
</web_search_result>
"odc-topology" "60000" Yup async validation openshift
<web_search_result>
I can't find a clear match for that exact phrase. Do you want me to:
- search GitHub/Red Hat issues and forums for "odc-topology" + "60000" + "Yup async validation" now, or
- help troubleshoot a specific error you’re seeing (paste the error/stack trace, OCP/Console version, and where the 60000 appears)?
Pick one and I'll proceed.
</web_search_result>
Based on the web search results and the limitations in accessing the repository, I can now provide a rewritten review comment. The web search confirmed that the Yup 0.27.0 to 1.7.1 upgrade does introduce performance regressions through increased async validation overhead, which validates the original review concern.
Verify necessity of 60-second timeout and investigate potential Yup-related performance regression.
The timeout increase to 60 seconds is significant. While the Yup 1.x upgrade can introduce performance regressions through increased async validation overhead (especially for Promise-based tests), it's unclear how form validation directly impacts topology page DOM rendering time unless there's form validation occurring on page load.
The high timeout value suggests one of three scenarios:
- A form on the topology page validates on mount, blocking the
.odc-topologyelement from becoming visible - The timeout is overly cautious and should be reduced after testing with the actual Yup v1 implementation
- An unrelated performance regression has been introduced
Before merging:
- Confirm whether forms exist on the topology page that validate on mount
- Measure the actual time needed for
.odc-topologyto become visible with this Yup version to determine if 60 seconds is required or excessive - If async validation is the root cause, consider mitigations: debouncing validation, deferring async checks to blur/submit, or validating off-page-load
A 60-second timeout could significantly slow test execution and mask real performance issues.
🤖 Prompt for AI Agents
frontend/packages/topology/integration-tests/support/pages/topology/topology-page.ts
lines 79-80: the test increased the wait timeout to 60s for the topology page
which is likely masking a performance/regression or an unnecessary over-guard;
confirm whether any forms on the topology page trigger async Yup validation on
mount and measure the actual time until '.odc-topology' becomes visible under
the current Yup v1 behavior, then replace the blanket 60s timeout with a
measured reasonable timeout (or remove it) and/or wait for a more specific
readiness signal (e.g., element that indicates form-ready, a specific
API/network call via cy.intercept, or an element text/state) and if async
validation is the cause, mitigate by debouncing/deferring validation or
adjusting the component so validation runs on blur/submit rather than on mount.
|
@krishagarwal278: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
QE approval: |
|
|
||
| Cypress.Commands.add('deleteProjectWithCLI', (name: string, timeout?: number) => { | ||
| cy.exec(`oc delete project ${name}`, { timeout }); | ||
| // First try normal delete, if it times out, force delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this sitll needed for e2e to pass?
| verifyToplogyPageNotEmpty: () => { | ||
| cy.get('*[class="odc-topology"]').then(($el) => { | ||
| // Wait for topology page to load completely - increased timeout for yup async validation | ||
| cy.get('[class*="odc-topology"]', { timeout: 60000 }).should('be.visible'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this existing timeout for cy.get not enough? does this mean that the topology page loads slower after this PR?
| // Wait for the button to be stable (not re-rendering) | ||
| cy.byTestID('reveal-values', { timeout: 30000 }).should('be.visible'); | ||
| // Add a small delay to ensure page is stable after any re-renders | ||
| // eslint-disable-next-line cypress/no-unnecessary-waiting | ||
| cy.wait(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this feels like we are masking some unnecessary rerendering problems
| @@ -1,5 +1,8 @@ | |||
| export const detailsPage = { | |||
| titleShouldContain: (title: string) => cy.get('[data-test="page-heading"] h1').contains(title), | |||
| titleShouldContain: (title: string) => { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still needed to get e2e to pass?
| const configJson = JSON.stringify(configFile); | ||
| cy.byLegacyTestID('file-input-textarea').clear().type(configJson, { | ||
| parseSpecialCharSequences: false, | ||
| delay: 50, // Slower typing to give validation time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be debouncing the input instead of typing slower? is there lag with the delay?
|
@XiyunZhao please help verify, thanks! |
Bump Yup from 0.27.0 to 1.7.1
Summary
Upgrades Yup validation library from 0.27.0 to 1.7.1, bringing native async validation support, improved type safety, and smaller bundle size (10.26 KB gzipped). Migrated 20+ validation files to comply with Yup 1.x breaking changes.
Key Changes
yup.mixed().test()functions to useasync/await(validate() now always returns Promise)yup.when().then()clauses to function-based pattern:(schema) => schema.concat(...)orschema.shape({...})yup@^1.7.1infrontend/package.jsonandfrontend/packages/vsphere-plugin/package.jsonMigration Pattern
Before:
After:
Files Modified
Core: buildconfig, deployments, health-checks, hpa, import validation schemas
Plugins: helm, knative, pipelines, shipwright, webterminal, metal3 validations
Public: configmaps validation
Tests: form-switcher-validation.spec.ts
Why This Matters
Testing
yarn test --testPathPattern="validation"and verify form validations in Pipeline builder, Build config, Deployment, ConfigMap, Helm, and Knative formsAdditional Info
Breaking Changes Addressed:
yup/lib/*imports)Risk Level: 🟡 Moderate - Validation logic preserved, straightforward rollback if needed
This PR Description is generated by Claude Code