Skip to content

Policy Field: Add MaxLen, Required Priority and Fix Decimal issues#3339

Merged
mareklibra merged 2 commits into
redhat-developer:mainfrom
asmasarw:fix/policy-screen
Jun 10, 2026
Merged

Policy Field: Add MaxLen, Required Priority and Fix Decimal issues#3339
mareklibra merged 2 commits into
redhat-developer:mainfrom
asmasarw:fix/policy-screen

Conversation

@asmasarw

@asmasarw asmasarw commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Tickets:

  • FLPATH-4270 | [DCM] Policy description field has no max-length validation
  • FLPATH-4269 | [DCM] Policy priority field accepts non-integer values
  • FLPATH-4271 | [DCM] Policy priority field not marked as required
  • FLPATH-4244 | [DCM] Normalize policy enabled checks for defensive coding
  • FLPATH-4255 | [DCM] Policy priority uniqueness constraint not communicated
  • FLPATH-4250 | [DCM] Whitespace-only values pass form validation for required policy fields

Changes:

Fix policy form validation for Description and Priority fields, normalize enabled
checks, and reject whitespace-only required fields.

  • Add a 255-character max-length Yup rule to the Description field, with inline error
    feedback matching the Display Name pattern (validation error on blur rather than
    hard-blocking input at the DOM level).
  • Add .integer() and .required() Yup rules to the Priority field so decimal values
    (e.g. 500.5) and an empty field are rejected with an explicit error message instead of
    silently coercing to an integer or defaulting to 500.
  • Add step={1} to the Priority number input and block ./e/E characters via
    onKeyDown and onChange guards to prevent decimal strings from bypassing the Yup
    integer check through JavaScript's Number() coercion.
  • Update the Priority label to "Priority *" to indicate it is a required field.
  • Update the Priority helper text to surface the API uniqueness constraint
    (priority must be unique per policy type) so users are informed before hitting a 409.
  • Normalize the three inconsistent enabled checks in PoliciesTabContent to
    p.enabled ?? true so the Enabled column, Actions toggle, and edit form all agree
    when enabled is undefined.
  • Add .trim() to the display_name and rego_code Yup rules so whitespace-only
    values are rejected client-side instead of passing validation and being silently
    rejected by the API after submit.

@asmasarw asmasarw requested review from a team, jkilzi and mareklibra as code owners June 9, 2026 12:30
@rhdh-gh-app

rhdh-gh-app Bot commented Jun 9, 2026

Copy link
Copy Markdown

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-dcm workspaces/dcm/plugins/dcm patch v1.0.0

@asmasarw asmasarw force-pushed the fix/policy-screen branch from 6c7d67a to 3f2ebbc Compare June 9, 2026 12:31
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.99%. Comparing base (0239de6) to head (717ab05).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3339      +/-   ##
==========================================
- Coverage   54.01%   53.99%   -0.03%     
==========================================
  Files        2402     2403       +1     
  Lines       87402    87613     +211     
  Branches    24207    24295      +88     
==========================================
+ Hits        47212    47304      +92     
- Misses      38694    38799     +105     
- Partials     1496     1510      +14     
Flag Coverage Δ *Carryforward flag
adoption-insights 83.58% <ø> (ø) Carriedforward from f5e034c
ai-integrations 70.03% <ø> (ø) Carriedforward from f5e034c
app-defaults 69.60% <ø> (ø) Carriedforward from f5e034c
augment 46.39% <ø> (ø) Carriedforward from f5e034c
bulk-import 72.86% <ø> (ø) Carriedforward from f5e034c
cost-management 17.48% <ø> (ø) Carriedforward from f5e034c
dcm 59.14% <37.50%> (-2.09%) ⬇️
extensions 62.24% <ø> (ø) Carriedforward from f5e034c
global-floating-action-button 74.30% <ø> (ø) Carriedforward from f5e034c
global-header 61.63% <ø> (ø) Carriedforward from f5e034c
homepage 51.52% <ø> (ø) Carriedforward from f5e034c
install-dynamic-plugins 56.23% <ø> (ø) Carriedforward from f5e034c
konflux 91.01% <ø> (ø) Carriedforward from f5e034c
lightspeed 68.52% <ø> (ø) Carriedforward from f5e034c
mcp-integrations 85.46% <ø> (ø) Carriedforward from f5e034c
orchestrator 37.33% <ø> (ø) Carriedforward from f5e034c
quickstart 62.09% <ø> (ø) Carriedforward from f5e034c
sandbox 79.56% <ø> (ø) Carriedforward from f5e034c
scorecard 83.84% <ø> (ø) Carriedforward from f5e034c
theme 64.54% <ø> (ø) Carriedforward from f5e034c
translations 8.49% <ø> (ø) Carriedforward from f5e034c
x2a 78.79% <ø> (ø) Carriedforward from f5e034c

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0239de6...717ab05. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@asmasarw asmasarw force-pushed the fix/policy-screen branch 2 times, most recently from 59f27d5 to 15067c9 Compare June 9, 2026 12:47
@asmasarw asmasarw force-pushed the fix/policy-screen branch from 49cae8e to f5e034c Compare June 9, 2026 12:55

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when p.enabled is undefined, !p.enabled is true, so “disable” still sends enabled: true.

Suggested change
enabled: !(p.enabled ?? true),

@sonarqubecloud

Copy link
Copy Markdown

@asmasarw asmasarw requested a review from mareklibra June 10, 2026 08:26
@mareklibra mareklibra merged commit 11dc527 into redhat-developer:main Jun 10, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants