tinacms / tinacms

A fully open-source headless CMS that supports Markdown and Visual Editing
https://tina.io
Apache License 2.0
11.32k stars 573 forks source link

Collection templates stopped working after updating from 1.4.6 to 1.5.0 #3870

Closed kslstn closed 1 year ago

kslstn commented 1 year ago

Describe the issue that you're seeing. Any Loom videos or screenshots usually help a lot!

For one collection, I've defined templates as described in the docs.

Tina CMS builds the dev server without error, but when I use the admin to navigate to the collection, it won't load, saying "Looks like there's nothing to edit on this page." I can't create new pages there either.

When I look at the browser I see the following errors: Uncaught TypeError: fields is undefined [...] The above error occurred in the component: [...]

Reproduction

https://github.com/kslstn/tina-issues/tree/templates

Steps to reproduce

Update:

dependencies:

devDependencies:

Then define a template as described in the docs.

System Info

System:
    OS: macOS 13.3.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
    Memory: 322.47 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    npm: 8.5.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 112.0.5615.137
    Edge: 112.0.1722.58
    Firefox: 112.0.1
    Safari: 16.4
    Safari Technology Preview: 16.4
  npmPackages:
    @tinacms/cli: ^1.5.7 => 1.5.7 
    tinacms: ^1.5.0 => 1.5.0

Validations

logan-anderson commented 1 year ago

@kslstn I was not able to reproduce this issue but I did notice a couple of other issues.

You can see this video for more info: https://www.loom.com/share/d28ec20d43f94f22a243953aa028ccc8

kslstn commented 1 year ago

Hi Logan, thank you for the detailed follow-up. In my tina-issues repo, the templates now work too. I wish it were the case for our real site too. I tried a fresh install and bit by bit I introduced my settings, but it still fails with the templates. I will try again tomorrow.

HenrySkup commented 1 year ago

I'm also noticing an issue with a collection that uses templates. I'm getting a pop up with :

[Error] GetCollection failed: Unable to fetch, errors: Error querying file content/consciousCollective/3f3eb861a3d5202fe75bec4c349e96fa06d43dcf.mdx from collection consciousCollective. Please run "tinacms audit" or add the --verbose option for more info

and in the terminal i'm getting

Error querying file content/consciousCollective/3f3eb861a3d5202fe75bec4c349e96fa06d43dcf.mdx from collection consciousCollective. Please run "tinacms audit" or add the --verbose option  for more info

GraphQL request:8:11
8 |           documents(sort: $sort, after: $after, first: $limit, filter: $filter, 
  |           ^
  | folder: $folder) @include(if: $includeDocuments) {

seems like an auto generated file? (the audit it running clean)

Update:

removal of templates has seemed to solve the issue

appinteractive commented 1 year ago

Seems it crashes due to the fields not being found: const sortField = fields.find

grafik

My Pages has multiple Templates, maybe that helps @logan-anderson

appinteractive commented 1 year ago

Tried to remove the templates and only use fields for testing, sadly it does not work. Pages is rendered but admin crashes

grafik

Update 1

Okay now it works (without templates) on my other collections too. Sadly I need the templates, it did work before and I also do not have any missing template definitions in frontmatter. Also does tinacms audit shows me that everything is okay.

But what I have since some time how is following error message which I did ignore as it did not break anything (until now)

❯ yarn tinacms audit
yarn run v1.22.19
$ /Users/Greg/Projekte/Mischa/grenzen-sind-relativ-tina/node_modules/.bin/tinacms audit
Starting Tina Audit
▲ [WARNING] Comparison with -0 using the "===" operator will also match 0 [equals-negative-zero]

    ../../../../../private/var/folders/mq/7pcgsjf108qgppygvpwr_z040000gn/T/1682674916854/config.build.jsx:184224:28:
      184224 │           } else if (x3 === -0) {
             ╵                             ~~

  Floating-point equality is defined such that 0 and -0 are equal, so "x === -0" returns true for
  both 0 and -0. You need to use "Object.is(x, -0)" instead to test for -0.

Indexing local files ⠙
Checking page collection. 135 Documents
Checking navMain collection. 1 Documents
Checking navFooter collection. 1 Documents
✅ Audit passed
✨  Done in 5.94s.

Inside the Admin, I get the following message about a file that does not exist:

grafik
logan-anderson commented 1 year ago

@HenrySkup, @appinteractive or @kslstn Are any of your repos that you are seeing this in public by any chance? (Or if your comfortable, temporarily give me access ?)

Or is there anyway you could produced a reproduction repo?

I am not able to reproduce this at this time.

pbougie commented 1 year ago

@logan-anderson I have a similar problem and can reproduce it. My current collection settings include:

path: "_src",
match: {
  include: "*/pages/*",
},

These settings no longer work. This is needed to pickup folders _src/en/pages/*.md and _src/fr/pages/*.md. However, if I change the settings to (only half my documents are listed):

path: "_src/en/pages",

Then it works as expected.

kslstn commented 1 year ago

Hi @logan-anderson, pbougie's solution didn't work for me. I've just invited you to our website's repo (kslstn/fortomorrow-website).

pbougie commented 1 year ago

@logan-anderson I've reproduced it here. Check the Blog Posts section.

https://github.com/pbougie/tinacms-20230419/commit/a45c3b7a74ec1dd7d6e1f6ffd02c97bdad2f85c7

logan-anderson commented 1 year ago

@kslstn and @appinteractive I have a PR pushed up for the can read property find of undefined issue

logan-anderson commented 1 year ago

@pbougie Can you describe the issue you are seeing and how to reproduce it? I don't see any issues in the admin interface on your reproduction site

UPDATE: My bad I forgot to run yarn install. I see the issue and hopefully can fix it.

logan-anderson commented 1 year ago

@kslstn @appinteractive @pbougie @HenrySkup Both of these issues should be fixed now. Please let us know if it is still happening on the latest version

pbougie commented 1 year ago

@logan-anderson I'm still getting an error but a different one. The first page now loads but when I select a subfolder, I get this error can't access property "breadcrumbs", document2._sys is undefined.

Screenshot 2023-05-01 at 09 22 19

I'm having difficulty reproducing it in a test project however. I have encountered another bug in my test project. Once going through a couple of folders, the documents don't load:

Screenshot 2023-05-01 at 09 29 06

To reproduce:

  1. Clone https://github.com/pbougie/tinacms-20230419
  2. yarn install and yarn dev
  3. Go to Blog Posts
  4. Select folders until you hit documents
  5. Select a document

Is there a way to disable the folders?

kldavis4 commented 1 year ago

@pbougie taking a look at this now

kldavis4 commented 1 year ago

I don't think the issue in your test project is related to the breadcrumbs error.

I was able to fix that one by doing the following:

  1. Rename pages/posts/[slug].js -> pages/posts/[...slug].js
  2. Change the mapping in getStaticPaths to: return { params: { slug: x.node._sys.relativePath.split('/') } };
  3. Change the relativePath in getStaticProps to: relativePath: ctx.params.slug.join('/'),
  4. Update the ui.router property on the post collection in tina/config.js to: ui: { router: ({ document }) => { return/posts/${document._sys.relativePath}; }, },

Any other details on the project with the breadcrumbs error would be helpful in determining the issue (you can also invite me to the github repository if it is private kldavis4)

kldavis4 commented 1 year ago

@pbougie do you have anywhere in your tina/config.js where there is a _sys.breadcrumbs (most likely in a ui.router)?

pbougie commented 1 year ago

@kldavis4 I'm not referencing _sys.breadcrumbs or using ui.router anywhere. My project is built with Eleventy.

kldavis4 commented 1 year ago

@pbougie ok, I'm happy to take a look if you want to invite me to your project. Otherwise I'll need a reproduction

pbougie commented 1 year ago

@kldavis4 Ok I've managed to reproduce it:

  1. Clone repo: https://github.com/pbougie/tinacms-20230501
  2. npm install
  3. npm run dev
  4. Go to http://localhost:8080/admin/
  5. Select Pages section
  6. Select en or fr
kldavis4 commented 1 year ago

@pbougie great - taking a look now

kldavis4 commented 1 year ago

@pbougie did you intend to disable create/delete for the pages collection?

pbougie commented 1 year ago

@kldavis4 Yes, they're a fixed number in my actual project.

kldavis4 commented 1 year ago

@pbougie ok - sounds good. I've found and fixed the issue. Thanks for the reproduction. I'll let you know once it is released

pbougie commented 1 year ago

@kldavis4 Great news, thanks.

kslstn commented 1 year ago

@logan-anderson with the latest release I can view the collections again, thank you!

appinteractive commented 1 year ago

Works thanks 👍

kldavis4 commented 1 year ago

@pbougie the fixes for your issue have been released

pbougie commented 1 year ago

@kldavis4 Thanks.