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

Form submission won't submit when file upload filed has a max or minimum file size via GraphQL #2281

Open
ryan-reason opened this issue Feb 6, 2025 · 1 comment

Comments

@ryan-reason
Copy link

Describe the bug

Using Formie through headless GraphQL API queries the file field won't submit when it has a max or a minimum file size set in the CMS.

Have attached the initial error messaging which references "Undefined array key \"path\" outlined in the file: "/var/www/html/vendor/verbb/formie/src/fields/FileUpload.php".

Just to clarify form file submissions go through correctly when a file upload field does not have a min or max file size set.

Error messaging

{
  "errors": [
    {
      "debugMessage": "Undefined array key \"path\"",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "file": "/var/www/html/vendor/verbb/formie/src/fields/FileUpload.php",
      "line": 248,
      ...
     }
  ]
}

Here is the Data I used specifically to have reference of:

Mutation Query

mutation MyMutation($file: [FileUploadInput]) {
  save_uploadFile_Submission(file: $file) {
    id
  }
}

Query Variables

{
  "file": [
    {
      "fileData": "data:image/jpeg;base64,/9j/4AAQSkZJR...",
      "filename": "image-test.jpg"
    }
  ]
}
Image

There is also a seperate issue when trying to access the volumeHandle: "Calling unknown method: verbb\\formie\\fields\\FileUpload::getVolume()"

Thanks

Steps to reproduce

  1. Create a form with a required file upload field.
  2. Set the field to have either a minimum or a maximum file size.
  3. Open the GraphiQL link in Craft CMS.
  4. Follow mutation and query variables (With your own data) outlined here in the docs: (https://verbb.io/craft-plugins/formie/docs/developers/graphql#file-upload-field)
  5. Submit

Form settings

  • Multi-page form: Yes or No
  • Submission Method: Ajax or Page Reload
  • Client-side Validation: Yes or No
  • Custom Form Templates: Yes or No

Craft CMS version

5.5.7

Plugin version

3.0.20

Multi-site?

No

Additional context

Uses Headless mode GraphQL API.

@engram-design
Copy link
Member

Ah yes, now that's a tricky situation, as these are data-provided files, we don't actually have a mechanism to validate their size. That would mean creating a temp version of the file, evaluating that, and then potentially removing it.

As such, for now I've fixed this error, but min/max sizes for GraphQL isn't something we enforce.

Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-5 as 3.0.20".

I'd recommend implementing what Formie does on your client-side code.

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

No branches or pull requests

2 participants