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

Conversation

shantanu73
Copy link
Contributor

Description of change

(write a short description or paste a link to JIRA)

  1. Added a new schema chat_webpath_array.json for chat webpath which validates array elements.
  2. Modified chats.json to include chat_webpath_array.json schema for webpath in chats API.

Manual QA steps

Risks

Rollback steps

  • revert this branch

1) Added a new schema chat_webpath_array.json for chat webpath which validates array elements.
2) Modified chats.json to include chat_webpath_array.json schema for webpath in chats API.
"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

"$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.

1) Removed chat_webpath_array.json and kept those changes in chat_webpath.json
2) Modified the order for data types, kept integer before string.
@shantanu73 shantanu73 requested a review from dbshah1212 April 26, 2022 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants