decaporg / decaporg/decap-cms

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

Open
#7,399 1 comment 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

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](https://jsssg.org/) through Decap CMS, specifically the `data` field that defines [global site data](https://jsssg.org/configuration/#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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the config.yml collection and file definition shown, then inspect the CMS editor's publish flow for a file field named data. Confirm that editing and publishing the field updates the file without the "No file found for undefined" error; the payload does not name a specific source file or test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.