Solved plugin bug

Hi

I’m on latest tests-passed (1.5.0beta7 +48) discourse with latest “solved” plugin and I have some problems while creating a new category.

Steps to repro (checked that on latest stable Chrome and IE11):

  1. Create a new category
  2. Tick “Allow users to accept answers” checkbox
  3. Images and Templates after ticking are not clickable

updates: Also many elements are not clickable - search icon, hamburger menu, profile, avatars…

After trying this I get error on /logs:

4 x Uncaught Error: Property set failed: object in path "custom_fields" could not be found or was destroyed. Url: http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js Line: 8 Column

Backtrace:

Error: Property set failed: object in path "custom_fields" could not be found or was destroyed.
    at new Error (native)
    at Error.r (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:7:1941)
    at l (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:8:720)
    at Object.u [as set] (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:8:146)
    at e.default.s.Mixin.create.set (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:11:13477)
    at set (http://example.com/assets/application-94d3f21e00d4c56244a228e913699af7.js:59:14809)
    at null.<anonymous> (http://example.com/assets/application-94d3f21e00d4c56244a228e913699af7.js:1:6056)
    at a.d._set (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:6:26209)
    at a.d.set (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:6:25840)
    at Object.u [as set] (http://example.com/assets/ember_jquery-c510009d3d7cecdf3f948f54d4922d9a.js:8:164)

PS: I don’t have any custom fields.

Do you have any other third party plugins installed? If so disable them all.

No. I have just tagging and solved plugin.

Was the site in English or another language?

Oops, I thought I already replied to this topic.

Few days ago I was looking into this issue and was able to repro this consistently. In fact I can repro this right now here on meta!


Repro Steps:

  1. Click “Create a new category” button.
  2. Open “Settings” tab.
  3. Tick “Allow topic owner and staff to mark a reply as the solution” checkbox.
  4. Notice there will be an error in console.

I tried to fix this issue and was able to pinpoint the code causing this issue:

https://github.com/discourse/discourse-solved/blob/master/assets/javascripts/discourse/pre-initializers/extend-category-for-solved.js.es6#L18

this.set("custom_fields.enable_accepted_answers", value);

^^ custom_fields is not defined when creating new category, however it is defined when editing the category.

I spent considerable time on this issue and was not sure how to fix this. :frowning:

@eviltrout can you look into this?


Also related:

https://meta.discourse.org/t/discourse-solved-accepted-answer-plugin/30155/108?u=techapj

7 Likes

Is this still an issue @techapj?

Yes, this bug still exists. Can repro here on meta.

3 Likes

I recently tried using the same code for adding category custom fields to a plugin and ended up getting the same error when attempting to add the custom field while creating a new category. The feature-voting plugin also uses the same pattern and produces the same error. Is there a way to get this to work so that custom fields can be added when creating a new category?

Quick and easy solutions are either disable the checkbox in the category-custom-fields connector if category.custom_fields is not defined, or to move the plugin’s category selection into site-settings.

1 Like

Hi, any progress on this? Is category.custom_fields still not defined while creating a new category?