Skip to content

"Error: No file found for undefined" when field has 'name: data' #7399

@ghost

Description

Describe the bug
If config.yml defines a file collection containing a file with a field with name: data, trying to publish changes to that file through the CMS causes an error toast with "Error: No file found for undefined in {collection name}" and the update fails.

To Reproduce
For me, this problem happens when I have the following in my config.yml (besides backend and some url and path configuration like media_folder etc). The important part is the name: data field in File.

collections:
  - label: 'Collection'
    name: collection
    files:
      - label: 'File'
        name: file
        file: file.json
        fields:
          - name: data

If I then open the CMS and open up the editor for File, any existing value for the 'data' field is shown as expected. However, if I edit that value and then press the button to publish, the error is shown ("Error: No file found for undefined in collection") and the update fails.

Expected behavior
Don't show an error and update the file.

Applicable Versions:

  • Decap CMS version: 3.6.1
  • Git provider: Codeberg.org
  • OS: Manjaro Linux
  • Browser version: Brave 1.75.175 Chromium: 133.0.6943.54 (Official Build) (64-bit)

Additional context
Some things that I found while investigating this problem:

  • To produce the error, the filename does not matter (eg file.json) and neither does the extension (tested with json and yml). Also the name values of the File and the Collection don't matter.
  • The error does not occur when name: data is used somewhere else in the config, ie for the file or the collection. The error only occurs when name: data is used for the field.
  • The error does not occur when name: data is changed to something else, like datax or field1.

A little background on why I want a field with name: data: I want to be able to edit (part of) the config file of JSSSG through Decap CMS, specifically the data field that defines global site data. I can think of workarounds to this error (like having the CMS edit a field called datax and then changing it to data in my build process, or something), but I'd rather not have to resort to that.

Is this indeed a bug, or am I doing something wrong here? I'd be very grateful for any insights! Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions