Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TDL-18578 : Errors Observed in Tap Failure Dashboard #41

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tap_zendesk_chat/schemas/chat_webpath_array.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"items": {
"type": [
"null",
"string",
"integer"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no meaning of putting integer after string so do put integer before the string in priority.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema is able to validate the input json irrespective of the order in which these data types are kept.
The integration tests ran fine and I've validated it through online schema validator as well.
So, wanted to confirm if you're suggesting it as a best practice or does it actually impact any given input ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that the singer.Transformer cares about the order.

Here's an example

$ python3
>>> from singer import Transformer
>>> schema = {
...   "type": "object",
...   "properties": {
...     "string-int": {"type": ["null", "string", "integer"]},
...     "int-string": {"type": ["null", "integer", "string"]}
...   }
... }
>>> records = [
...   {"string-int": 1, "int-string": 1},

...   {"string-int": "2", "int-string": "2"}
... ]
>>> with Transformer() as tm:
...   for record in records:
...     print(tm.transform(record, schema))
...
{'string-int': '1', 'int-string': 1}
{'string-int': '2', 'int-string': 2}

Notice that

  1. string-int is a field that prioritizes string
  2. int-string is a field that prioritizes integer
  3. The transformer forces string-int to be output as a string
  4. The transformer forces int-string to be output as an integer

]
},
"type": [
"null",
"array"
]
}
12 changes: 10 additions & 2 deletions tap_zendesk_chat/schemas/chats.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@
},
"webpath": {
"items": {
"$ref": "chat_webpath"
"anyOf": [
{
"$ref": "chat_webpath"
},
{
"$ref": "chat_webpath_array"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating 2 separate files, we can also put anyOf inside the chat_webpath file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, will make this change.

}
]
},
"type": [
"null",
Expand Down Expand Up @@ -197,6 +204,7 @@
"chat_history",
"chat_response_time",
"chat_visitor",
"chat_webpath"
"chat_webpath",
"chat_webpath_array"
]
}