SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.16k stars 659 forks source link

[Bug]: TypeError when deleting an image from array #1487

Open marinadeotti opened 1 year ago

marinadeotti commented 1 year ago

What happened?

When using the upload feature with "multiple: true", when I delete an image that has been uploaded and try to save, I get the error:

TypeError: record.get(...).filter is not a function

Apparently the filesToDelete option is not being able to filter the array of images.

Bug prevalence

Trying to update an array of images

AdminJS dependencies version

{ "dependencies": { "@admin-bro/express": "^3.1.0", "@admin-bro/mongoose": "^1.1.0", "@admin-bro/upload": "^1.3.1", "@adminjs/upload": "^3.0.0", "@aws-sdk/client-s3": "^3.321.1", "@material-ui/core": "^4.12.4", "@material-ui/icons": "^4.11.3", "@material-ui/lab": "^4.0.0-alpha.61", "add": "^2.0.6", "admin-bro": "^4.0.1", "assert": "^2.0.0", "aws-sdk": "^2.1365.0", "bcrypt": "^5.1.0", "browserslist": "^4.21.4", "buffer": "^6.0.3", "cookie-parser": "^1.4.6", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.1", "express-formidable": "^1.2.0", "express-session": "^1.17.3", "fs": "^0.0.1-security", "koa": "^2.13.4", "koa-mount": "^4.0.0", "koa-static": "^5.0.0", "material-ui-dropzone": "^3.5.0", "mongoose": "^7.0.5", "mongoose-slug-generator": "^1.0.4", "os": "^0.1.2", "path": "^0.12.7", "prop-types": "^15.8.1", "react-dropzone": "^14.2.3", "rollup-plugin-includepaths": "^0.2.4", "safe-buffer": "^5.2.1", "slugify": "^1.6.5", "tinymce": "^6.3.1", "tslib": "^2.4.0", "url": "^0.11.0", "util": "^0.12.4", "uuid": "^9.0.0" }, "scripts": { "dev": "nodemon admin.js", "start": "node admin.js" }, "devDependencies": { "@rollup/plugin-commonjs": "^22.0.2", "@rollup/plugin-node-resolve": "^14.1.0", "nodemon": "^2.0.22", "rollup-plugin-polyfill-node": "^0.12.0" } }

What browsers do you see the problem on?

Chrome

Relevant log output

TypeError: Cannot read properties of undefined (reading '0')

Relevant code that's giving you issues

features: [
        uploadFeature({
          provider: {
            aws: { KEYS GO HERE },
          },
          properties: {
            file: "Imagens",
            filePath: "image.path",
            filesToDelete: "image.filesToDelete",
            key: "imageUrl",
            mimeType: "imageMimeType",
          },
          validation: imageValidation,
          multiple: true
        }),
      ],