Skip to content
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

fix: format-create-segment-errors-from-payload #5082

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Zaimwa9
Copy link
Contributor

@Zaimwa9 Zaimwa9 commented Feb 7, 2025

Thanks for submitting a PR! Please check the boxes below:

  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Issue: #5071
Fixes #5071

Please describe.
The payload was passed as of from the request response.

  • Added typing of error
  • Implemented a formatError method in CreateSegment
  • Prefixed the error with value/property
  • If single error, only returns a string (to keep Rules: XXXXX), if multiple errors, returns an array that is natively handled by the error component (but displays them as indexed list)

⚠️ This is more a hotfix than a permanent solution. The payload seems to be redundant with rules, cf type being, could be fixed in the backend:

type CreateSegmentError = {
  status: number,
  data: {
    rules: [{
      rules: Array<{
        conditions: SegmentConditionsError[]
      }>
    }]
  }
}

Also please let me know if you have a better solution to handle multiple errors, the best would be something like the following but maybe you have other plans/prio:

Rule 1:
 - value XXX
Rule 4: 
 - property: YYY
 - value: XXX

How did you test this code?

Single error case
image

Multiple error case (to be improved)
image

Please describe.

@Zaimwa9 Zaimwa9 requested a review from a team as a code owner February 7, 2025 11:16
@Zaimwa9 Zaimwa9 requested review from kyle-ssg and removed request for a team February 7, 2025 11:16
Copy link

vercel bot commented Feb 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Feb 7, 2025 11:16am

Copy link

vercel bot commented Feb 7, 2025

@Zaimwa9 is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Uffizzi Ephemeral Environment deployment-60728

☁️ https://app.uffizzi.com/github.com/Flagsmith/flagsmith/pull/5082

📄 View Application Logs etc.

What is Uffizzi? Learn more!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad error message rendering when failing to update segment
1 participant