Closed pdelboca closed 4 years ago
To clarify, does it happen on the first version if you add additional versions? e.g.
Will this also fail?
Was able to reproduce this but only when editing the name, not the description. At some point, when I only had 1 tag, I could also edit the name. I'm not sure if this is intermittent or if a more complex set of preconditions is at play here.
I think this is a JS issue (!) that happens because somewhere the name of the current tag, only if it is looks like a decimal value ("1.0", "2.0") etc. gets converted to a float and then back into a string. The result is that the wrong tag name is sent in the action POST request:
I think that CKAN's way of using data-module-...
variables for JS modules is to blame here, and we'll see if I can figure out a way to work around this. This may explain why this seemed "intermittent" earlier - because it only happens when version names look like a float (working to validate this hypothesis).
To be more exact: failure happens when the previous tag name is something that looks like a decimal, but that if converted to a string in JS will have different representation. Example:
1.0
will fail because it will be cast to the string "1"
1.1
will not fail because it will be cast to the string "1.1"
and thus will be found by the server1.20
will fail because it will be cast to "1.2"
not-a-number
will not fail because no casting to float happens. Happens because CKAN will first try to JSON-parse module options, so anything that looks like a JSON float will be treated as such (see https://github.com/ckan/ckan/blob/master/ckan/public/base/javascript/module.js#L382).
Workaround is to JSON-encode tag names before putting them in the template. This can also avoid other issues e.g. if tag names contained some special characters.
When editing a the first Version and using a
github
backend (so far it does not happen withfilesystem
backend) and error is raised:This is weird because it only happens when trying to edit the first Version of a Dataset, but it works correctly when trying to edit other versions of the same dataset.
How to reproduce: