6

As of the instant this question was posted, the tag has zero questions, but still exists in the system and has not been cleaned up yet. Just as a curiosity, I decided to test if users without enough rep to create tags could use such zero-question tags, and it turns out they can't.

However, the error message when doing so is a nondescript "An error occurred when submitting the edit":

An error occurred when submitting the edit.

Can this error message be changed to something more descriptive?

Update: Apparently, another such user was able to actually suggest an edit to add this very tag, without getting an error message: https://meta.stackexchange.com/review/suggested-edits/56358

9

So, this is perhaps not a problem with the error message as such...

This error occurs during the last stage of edit submission, right before the suggested edit is created in the database. At this stage, there are a handful of sanity-checks that run, to make sure that:

  1. There isn't already another suggested edit pending
  2. All submitted tags exist
  3. The normalized title, body and tags aren't all empty

This is not the complete set of validation checks - those run earlier, and there are a LOT more of them. But if any of these checks fail, the routine throws an exception and the request fails with a 500 error (and an appropriately opaque error is displayed to the editor).

Arguably, check #2 is a bit of an odd one out since it doesn't actually prevent the creation of an invalid suggestion so much as it just enforces some constraints on the content of that suggestion (and nowhere near all of the necessary constraints - for example, it doesn't check for the use of moderator-only or blacklisted tags). It doesn't even do anything to prevent those weird race conditions wherein a tag is removed by the system mid-edit, since there's no telling how long the suggestion will sit in the queue.

But those oddities aren't the real problem here. The problem is that it performs a check that isn't done anywhere else: it disallows tags that exist but have a use-count set to 0 in the Tags table.

Try this: instead of suggesting a 0-use tag, suggest an edit with a completely bogus tag, like . You get a nice detailed error back immediately.

Or try this: suggest the addition of a tag that has been removed from all questions but hasn't had its internal use-count updated yet (tag name autocomplete lists a number next to it). It goes through just fine.

Better yet, try this: as a brand-new user with 1 rep, try asking a question and using a 0-use tag. The system lets you do so without complaint.

In short, while preventing the addition of extant but unused tags might actually be a good idea... It isn't enforced anywhere else. So I would consider that the real bug here: the last-minute sanity-check doesn't match the rest of the validation performed on the edit.

Recommended fix:

Either remove sanity-check #2 entirely, or bring it in line with the rest of the tag validation (which is to say, simply verify that the tags exist, and ignore how often they've been used).

  • From a user perspective, it appears that it's just a nondescript error message. Hence, the report was phrased like this. Did you suggest the edit to my question? – Sonic the Anonymous WizHog Feb 9 '18 at 18:11
  • Yes, I did a thorough amount of testing on this before answering to verify that 1) you do get a proper error message in scenarios where you're actually trying to create a new tag and 2) you get proper error messages for all the other possible validation errors. This scenario is the odd one out because there's no matching validation step and hence nothing to generate an error - an alternate fix would be to add the 0-use check to validation, but I consider this suboptimal as it would be confusing and inconsistent with the rest of the system. – Shog9 Feb 9 '18 at 18:13
  • The "recommended fix" you propose would either way allow users without enough rep to create tags to use zero-use tags in edits. This can be a problem on sites such as Super User. There should definitely be a check to make sure those are not being used. – Sonic the Anonymous WizHog Feb 9 '18 at 18:20
  • 1
    Any user asking a question can already use 0-use tags if they currently existing in the system, @Ano. There's never been a restriction on this apart from suggesting edits, so far as I can discern - and even the one in the suggested edit pipeline isn't reliable, as it depends on the state of the tag engine at the moment the edit is submitted (and NOT when the edit is applied). – Shog9 Feb 9 '18 at 19:03
  • What about users who have CW editing privileges, but not tag-creation privileges? Can they edit a CW question to use a zero-use tag? – Sonic the Anonymous WizHog Feb 10 '18 at 17:40
  • I would expect so, @Ano - again, this is the only check for tag count I've seen; the very fact that this triggers a last-minute exception in the suggested edit code rather than an earlier validation error suggests this is a unique code path; users with edit permissions go through a different path after validation, one which does not have this zero-use check. – Shog9 Feb 10 '18 at 17:52
  • Interestingly enough, if you try this from the API, you get a meaningful error, "You can not suggest new tags as part of an edit suggestion". There are several layers of somewhat redundant validation on submission and error you're getting here is that nowhere else cares about tag count and the calling method does not turn the exception into a message. I'm inclined to just surface the message because what if a zero-use tag is suggested, then the tag is purged, then a user who can't create tags approves the edit? – Brian Nickel Feb 13 '18 at 21:35
  • That also happens, @Brian - I've seen it happen while someone was asking a question (the scheduled task ran and removed the tag they'd already selected). indeed, it's more likely to happen in the time between the edit's submission and approval than between selection and submission. The reverse is also true; the tag which prompted this report flipped back to a count of 1 while I was researching it, allowing me to submit a suggested edit even though at the time of submission it was unused. There are tons of unlikely race conditions that happen at Stack Overflow's scale ;-) – Shog9 Feb 13 '18 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .