[Bug] tk-core v0.20.15 introduces breaking bug

Hi,

The tk-core team accidentally introduced a bug in v0.20.15 release.

The commit in question is 7606eb59c6e91f15bd60baaef13fa34dab7cbd2d.

The change looked innocuous however if the context attribute ever doesn’t contain a “type” or a “name”, it previously would put “None” into the string because the old style string formatting would do that for you.

When using six.ensure_str you will instead have an exception thrown.

This bit our team here pretty hard today because all we had done was update a minor version of tk-core and it took us a long time to determine where the issue came from.

We are encountering this issue because our internal delivery tool runs in the context of a Version entity which toolkit doesn’t correctly pull a “name” value for when queried off of the context.entity attribute.

If there is something that we should be doing to ensure the Version entity works well with the Context class, please let me know, however I feel that regardless, there should be some guards on this code in case six.ensure_str does throw an error.

It also looks like the v0.20.15 release is not present in the Release thread.

Let me know if you need any more information or if you agree with this assesment.

Thanks
-Alex

5 Likes

Hello Alex, thank you for sharing this finding.

The first quick solution that comes to my mind is to change expression like this p.get("name") to something like p.get("name", "None"). This can ensure type safety returned by the dictionary get method and prevent errors on ensure_str.

Let me know if this makes sense. On our team we are going to do more research and work on a fix.

3 Likes

Hi @carlos-villavicencio

Yes that would work for me, or p.get("name", ""), either or is fine with me.

Thanks!
-Alex

2 Likes