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

feat: Improve error messages for invalid submissions #2533

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Koc
Copy link
Collaborator

@Koc Koc commented Jan 29, 2025

Right now it is really hard to understand for end users why form can't be submitted. This PR aims to improve validation messages.

@Koc Koc force-pushed the feature/improve-error-messages branch from bd658c4 to 23b8286 Compare January 29, 2025 15:13
@Koc Koc force-pushed the feature/improve-error-messages branch from 23b8286 to a82cc79 Compare January 29, 2025 15:22
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.38%. Comparing base (f8fca97) to head (a82cc79).
Report is 13 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2533      +/-   ##
============================================
- Coverage     43.40%   43.38%   -0.03%     
+ Complexity      882      881       -1     
============================================
  Files            77       77              
  Lines          3359     3356       -3     
============================================
- Hits           1458     1456       -2     
+ Misses         1901     1900       -1     

@Koc Koc requested review from Chartman123 and susnux January 29, 2025 15:27
@Chartman123 Chartman123 added enhancement New feature or request php PHP related ticket 3. to review Waiting for reviews labels Jan 29, 2025
@Chartman123 Chartman123 changed the title Improve error messages for invalid submissions feat: Improve error messages for invalid submissions Jan 29, 2025
@Chartman123 Chartman123 added this to the 5.0 milestone Jan 29, 2025
Copy link
Collaborator

@Chartman123 Chartman123 left a comment

Choose a reason for hiding this comment

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

Nice one :)

Copy link
Collaborator

@susnux susnux left a comment

Choose a reason for hiding this comment

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

I dont think this makes sense, what is the use case?
It is nothing shown to end users, that should already be done in the frontend and if it is not then there is a bug in the frontend that should be fixed.

So this is for developers that use the API?
In this case we should refactor the function at all (validateSubmission) to be void and throw instead on error.
Either InvalidArgumentException if we keep this developers only I would prefer this.
Otherwise an \OCP\HintException which would allow translated error messages for frontend - but here again we should never allow to submit something invalid so a frontend validation is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement New feature or request php PHP related ticket
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants