Skip to content

Commit 2d1d864

Browse files
authored
Avoid parsing Text Plugin metadata b"{}" (#5972)
## Motivation for features / changes There is a library that emits b"{}" as the plugin's metadata, which triggers 500 errors in the Text Plugin server code ([b/250789176](https://b.corp.google.com/issues/250789176)): ``` google3.net.proto2.python.public.message.DecodeError: Error parsing message with type 'tensorboard.TextPluginData' ``` ## Technical description of changes This commit handles the edge case by returning a TextPluginData default proto without parsing the metadata. ## Screenshots of UI changes - For the edge case that feeds in b"{}", users will see something like <img width="1213" alt="image" src="https://user-images.githubusercontent.com/88216042/195389659-a75660ce-01e4-4ecd-ace3-19b11cadfa07.png"> rather than an "Internal server error" page. ## Detailed steps to verify changes work correctly (as executed by you) Open the browser and enter the TextPlugin metadata endpoint of an experiment that generates the invalid metadata, e.g. `experiment/4725997998739972179/data/plugin/text/tags` and you should see the resulting valid metadata.
1 parent a818804 commit 2d1d864

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tensorboard/plugins/text/metadata.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ def parse_plugin_metadata(content):
5353
"""
5454
if not isinstance(content, bytes):
5555
raise TypeError("Content type must be bytes")
56+
if content == b"{}":
57+
# Old-style JSON format. Equivalent to an all-default proto.
58+
return plugin_data_pb2.TextPluginData()
5659
result = plugin_data_pb2.TextPluginData.FromString(content)
5760
if result.version == 0:
5861
return result

0 commit comments

Comments
 (0)