Skip to content

Conversation

@Deekshit014
Copy link

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 /data endpoint using the multipart/form-data content type but omitted the required filename, 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

  • Bug fix
  • New feature added
  • Documentation Update

Please make sure to follow these points

  • I have read the contributing guidelines.
  • I have performed a self-review of my own code or work.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generates no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • My changes have sufficient code coverage (unit, integration, e2e tests).

Screenshots (If Applicable)


Other Information

The fix was applied in internal/apiserver/route_post_data.go within the CoreFormUploadHandler. I inserted the check for r.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.

@Deekshit014 Deekshit014 requested a review from a team as a code owner October 10, 2025 05:16
@Deekshit014 Deekshit014 force-pushed the fix/misleading-error-220 branch from 6cd4c37 to 4cc3525 Compare October 10, 2025 05:18
Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Thanks @Deekshit014 for the PR - a few comments and changes needed. Would be great to add a test for the new validation

@@ -0,0 +1,7 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

@@ -0,0 +1,4 @@
info:
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Comment on lines +62 to +65
// Check for file upload
if r.Part == nil || r.Part.FileName() == "" {
return nil, i18n.NewError(r.Req.Context(), coremsgs.MsgMissingFileUpload)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarity this is what changed

Comment on lines +28 to +36
// @Summary Update an identity
// @ID patchUpdateIdentity
// @Tags identities
// @Accept json
// @Produce json
// @Param iid path string true "Identity ID" <-- THE CRITICAL FIX
// @Param body body core.IdentityUpdateDTO true "Identity update details"
// @Success 202 {object} core.Identity
// @Router /identities/{iid} [patch]
Copy link
Contributor

Choose a reason for hiding this comment

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

These remind me of sprint boot tags, where did you get these from?

"github.com/hyperledger/firefly/pkg/core"
)

// @Summary Get identity by ID
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto it would be significant decisions to bring in a DSL for describing APIs since we already have within ffapi the ability to describe the API and transform it to an OpenAPI document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get a misleading error message when uploading file to data endpoint without setting a file name

2 participants