Fix: Provide clear error when filename is missing on /data endpoint (Fixes #220) #1705
+153
−87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
Please include a summary of the changes here and why we need those changes. And also let us know which issue is fixed.
This Pull Request resolves Issue #220.
The issue was that when a developer attempted to upload data to the
/dataendpoint using themultipart/form-datacontent type but omitted the requiredfilename, the API returned a generic or confusing validation error.The change introduces an explicit check at the start of the form upload handler to ensure the file part and filename are present, returning a clear, user-friendly error message (
MsgFilenameRequired) instead of letting the request fail later with a misleading error.Fixes #220
Types of changes
Please make sure to follow these points
Screenshots (If Applicable)
Other Information
The fix was applied in
internal/apiserver/route_post_data.gowithin theCoreFormUploadHandler. I inserted the check forr.Part == nil || r.Part.FileName == ""at the start of the handler to ensure the error is returned at the point of validation, leading to better developer experience.