Solved plugin bug

AI-generated summary

Users reported a bug in the Discourse “solved” plugin where clicking the “Allow users to accept answers” checkbox while creating a new category causes UI elements to become unresponsive and triggers a JavaScript error: Property set failed: object in path "custom_fields" could not be found or was destroyed axp. techAPJ confirmed the issue and identified the root cause in the plugin’s code: the script attempts to set custom_fields.enable_accepted_answers before the custom_fields object is initialized during the category creation process, whereas it works correctly when editing an existing category. simon noted that other plugins using similar patterns for custom fields face the same limitation. Proposed workarounds include disabling the checkbox in the connector if category.custom_fields is undefined or moving the configuration to site settings. leo.proctor and codinghorror followed up to inquire about the status, with techAPJ confirming the bug persists on the Meta site.

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 Mi Piace

Is this still an issue @techapj?

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

3 Mi Piace

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 Mi Piace

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