Plugin Working in Local Instance, Breaking on Deployed

Hello! This is primarily a question for @angus but if anyone has any suggestions I would be very grateful!

I had been working on a variation of @angus Topic Custom Field Plugin and had it working as desired in my locally hosted instance of discourse (version 3.4.0.beta3-dev). Once I installed it on our deployed instance of discourse (also version 3.4.0.beta3-dev), something strange is happening. When a user writes a new post and puts an input into the custom field, it doesn’t save it or render it when the user makes the post. BUT if the user edits the post and then adds the input, it saves it and renders it. So this points me to it breaking somewhere in the connectors (presumably the composer connector), but I can’t figure out why as it works perfectly in my local instance. I have some regex that filters inputs, maybe this could be the culprit? Any suggestions are greatly appreciated, Thank you!

1 Like

It’s hard to debug this in the abstract, so I’m going to give you some advice instead. The key to figuring out the answer to any problem like this is focus, and process of elimination. Start with figuring out why you can reproduce the issue in production but not in development.

  1. Are the plugins and the themes exactly the same in production and development?
  2. Are you using the same kind of user (admin mod etc)?
  3. Are you performing the actions in the same kind of topic?
  4. Are you performing the actions at the same speed?

Start by doing all you can to try to reproduce the issue in development, if indeed there is an issue. Focus on that until you get results or figure out why it’s different in production.

Also, part of the reason that the Topic Custom Fields plugin is not intended for production use is that it doesn’t have any tests. I know you’re not going to like hearing this, but you should write some acceptance tests for the composer behaviour. That will give you a definitive answer as to whether it works in particular scenarios or not.

1 Like

I’m not sure if this would help but it seems like the issue might be that the custom field isn’t being set up properly when creating a post.

Make sure you’re assigning a default value to the field when the composer opens.

You could also try disabling your regex filter temporarily to check if it’s causing any validation problems. Lastly, double-check that the custom field is actually being included in the data sent during the initial save.

2 Likes