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

In version 3.2.0 publish fails if non-repeateable component data is "null" #8221

Closed
Stanko opened this issue Oct 7, 2020 · 4 comments · May be fixed by songshansitulv/strapi#171
Closed

Comments

@Stanko
Copy link
Contributor

Stanko commented Oct 7, 2020

Describe the bug

When trying to publish an entity that has non-repeateable component and component is not filled in, publish fails with an error.

I'll open a PR in a minute.

Steps to reproduce the behavior

In the Content-Types Builder:

  • Create a component (I called it publish-test-component)
  • Create a collection type (I called it PublishTest)
  • Add two fields to it
    • name - text field
    • component - select the component we created publish-test-component, and for the "Type" select "Single Component"

Go and create a new PublishTest:

  • Fill in the name field
  • Click "Save"
  • Click "Publish"
  • You'll get this error in the console:
    Uncaught TypeError: can't convert null to object
      getDraftRelationsCount getDraftRelations.js:4
    

Expected behavior
Page is published with no errors.

Screenshots

Dummy collection type I created for this test, it is important that the component's type is set to "Single Component":
Screen Shot 2020-10-07 at 1 47 41 PM

When hitting publish, if component has no data, publish fails:
Screen Shot 2020-10-07 at 1 45 06 PM

As you can see, data is null and Object.keys(data) on line 5 fails:
Screen Shot 2020-10-07 at 1 46 13 PM

System

I don't think these matter, but still I filled it in:

  • Node.js version: v12.16.1
  • NPM version: 6.14.5
  • Strapi version: 3.2.0
  • Database: sqlite
  • Operating system: macOS
@alexandrebodin
Copy link
Member

Hi, thanks for the notice. This issue is a duplicate of #8220. I'm going to close this one :)

@Stanko
Copy link
Contributor Author

Stanko commented Oct 7, 2020

Sorry, I've searched through the issues, but missed that one 🙈

alexandrebodin pushed a commit that referenced this issue Oct 7, 2020
… is "null" (#8222)

Signed-off-by: Stanko <stanko.tadic@gmail.com>
@hadynz
Copy link

hadynz commented Oct 7, 2020

Not related to the issue anymore since it has been resolved -

@Stanko i ran into the same issue last night and struggled a lot debugging it because strapi code is always minified. I couldn't even add debugger statements.

I can see you didn't have the problem. Wondering how that was the case as it would help me in the future contributing more thoroughly to the project?

@Stanko
Copy link
Contributor Author

Stanko commented Oct 8, 2020

Hey @hadynz, code is minified, but strapi team provides source maps as well. When error happens, development tools (I use firefox) will show you exactly in which file it happened. Then you can edit it in the node modules, but this can be cumbersome as you need to restart the app. Or just copy the file to your project's folder, check the official documentation:

https://strapi.io/documentation/v3.x/admin-panel/customization.html#development-mode

Now strapi will use the local file instead of the one from the node modules, and you can patch the bug locally. Then I just take that patch and create a PR back to this repo.

Hope that helps, cheers!

EDIT: I think you have to use strapi's development mode strapi develop --watch-admin

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

Successfully merging a pull request may close this issue.

3 participants