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

Source ZohoCRM: Update api version and default optional fields to None #27423

Conversation

richardlam-quotapath
Copy link
Contributor

What

The API Version was out of date which was causing issues because the v2 version has some modules return meta data with missing required fields.
Example: The deals endpoint with our customer's credentials was missing the "json_type" and "length" fields in the meta data which was causing the deals stream to not be available.
Also the optional fields in the FieldMeta class were not actually optional because they weren't being defaulted to None, local testing of that isolated code shows that if we have data missing the picklist_values field (which is supposed to be optional), the init() would fail because it wasn't being defaulted to None.
image

How

Fix #1
Update the zohocrm api version from v2 to v4
This will solve the ZohoCRM API returning data that is missing required fields issue

Fix #2
Have the class FieldMeta's optional fields be defaulted to None
This will solve the FieldMeta's init() failing on valid data due to missing optional fields issue

Re-testing shows the deals stream now available
image

Recommended reading order

This shows that dataclasses optional fields must be defaulted to a value
https://stackoverflow.com/questions/70809438/python-dataclasses-with-optional-attributes

🚨 User Impact 🚨

Some of our clients were not seeing key streams such as Deals due to this issue

Pre-merge Actions

Expand the relevant checklist and delete the others.

New Connector

Community member or Airbyter

  • Community member? Grant edit access to maintainers (instructions)
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Connector version is set to 0.0.1
    • Dockerfile has version 0.0.1
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • docs/integrations/<source or destination>/<name>.md including changelog with an entry for the initial version. See changelog example
    • docs/integrations/README.md

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Unit & integration tests added

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • If new credentials are required for use in CI, add them to GSM. Instructions.
Connector Generator
  • Issue acceptance criteria met
  • PR name follows PR naming conventions
  • If adding a new generator, add it to the list of scaffold modules being tested
  • The generator test modules (all connectors with -scaffold in their name) have been updated with the latest scaffold by running ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates then checking in your changes
  • Documentation which references the generator is updated as needed

@github-actions
Copy link
Contributor

Before Merging a Connector Pull Request

Wow! What a great pull request you have here! 🎉

To merge this PR, ensure the following has been done/considered for each connector added or updated:

  • PR name follows PR naming conventions
  • Breaking changes are considered. If a Breaking Change is being introduced, ensure an Airbyte engineer has created a Breaking Change Plan and you've followed all steps in the Breaking Changes Checklist
  • Connector version has been incremented in the Dockerfile and metadata.yaml according to our Semantic Versioning for Connectors guidelines
  • Secrets in the connector's spec are annotated with airbyte_secret
  • All documentation files are up to date. (README.md, bootstrap.md, docs.md, etc...)
  • Changelog updated in docs/integrations/<source or destination>/<name>.md with an entry for the new version. See changelog example
  • The connector tests are passing in CI
  • You've updated the connector's metadata.yaml file (new!)
  • If set, you've ensured the icon is present in the platform-internal repo. (Docs)

If the checklist is complete, but the CI check is failing,

  1. Check for hidden checklists in your PR description

  2. Toggle the github label checklist-action-run on/off to re-run the checklist CI.

Copy link
Contributor

@sajarin sajarin left a comment

Choose a reason for hiding this comment

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

Thanks for updating the api and cleaning up the code:

Can you bump the version in the metadata.yaml file?

Can you add a changelog entry to zohocrm.md in the docs directory?

@richardlam-quotapath richardlam-quotapath force-pushed the 27422-source-zoho-crm-api-version-out-of-date-and-optional-fields-arent-defaulted-to-none branch from e617a36 to 7aa6e39 Compare July 3, 2023 17:05
@octavia-squidington-iii octavia-squidington-iii added the area/documentation Improvements or additions to documentation label Jul 3, 2023
@richardlam-quotapath
Copy link
Contributor Author

Thanks for updating the api and cleaning up the code:

Can you bump the version in the metadata.yaml file?

Can you add a changelog entry to zohocrm.md in the docs directory?

Yup bumped the version and added a changelog entry

@sajarin
Copy link
Contributor

sajarin commented Jul 7, 2023

@richardlam-quotapath, apologies for the delay with merging this. Currently, this connector is not passing our integration tests due to some api regressions and other errors: https://connectors.airbyte.com/files/generated_reports/test_summary/source-zoho-crm/index.html

We need to fix these issues first before merging.

@richardlam-quotapath
Copy link
Contributor Author

@richardlam-quotapath, apologies for the delay with merging this. Currently, this connector is not passing our integration tests due to some api regressions and other errors: https://connectors.airbyte.com/files/generated_reports/test_summary/source-zoho-crm/index.html

We need to fix these issues first before merging.

Ah I see, it's not passing an acceptance test. I could take a look at the cause

Copy link
Member

@marcosmarxm marcosmarxm left a comment

Choose a reason for hiding this comment

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

Sorry the delay to return to you @richardlam-quotapath I left some comments. Let me know if there anything else I can do to help you. When you fix them we can merge your contribution.

Comment on lines +47 to +48
fields = ",".join([field.api_name for field in self.module.fields][0:50]) # Note, limited to 50 fields at max
return f"/crm/v4/{self.module.api_name}?fields={fields}"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fields = ",".join([field.api_name for field in self.module.fields][0:50]) # Note, limited to 50 fields at max
return f"/crm/v4/{self.module.api_name}?fields={fields}"
if len(self.module) > 50:
logger.warn("ZohoCRM only allow maximum of 50 parameter per query, the connector will drop: self.module.fields[50:]")
fields = ",".join([field.api_name for field in self.module.fields][0:50])
return f"/crm/v4/{self.module.api_name}?fields={fields}"

Comment on lines -95 to -103
def request_headers(
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
) -> Mapping[str, Any]:
last_modified = stream_state.get(self.cursor_field, self._start_datetime)
# since API filters inclusively, we add 1 sec to prevent duplicate reads
last_modified_dt = datetime.datetime.fromisoformat(last_modified)
last_modified_dt += datetime.timedelta(seconds=1)
last_modified = last_modified_dt.isoformat("T", "seconds")
return {"If-Modified-Since": last_modified}
Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing this?

@sajarin
Copy link
Contributor

sajarin commented Aug 1, 2023

hey @richardlam-quotapath thanks for the contribution. Are you able to respond to the changes requested above?

@sajarin
Copy link
Contributor

sajarin commented Aug 7, 2023

hey @richardlam-quotapath are you able to continue the PR? For now we'll close it and reopen once you have the time.

@sajarin sajarin closed this Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation community connectors/source/zoho-crm team/tse Technical Support Engineers
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants