airbyte
airbyte copied to clipboard
🐛 [source-linkedin-ads] fix re-adding sponsored content stream
What
This pull request recovers the removed Ad Sponsored Content stream, and therefore solve the issue described here. To summarize the issue, this stream was removed without explanation and ingested data from an important and still usable Linkedin endpoint (doc here).
Fixes (https://github.com/airbytehq/airbyte/issues/35635)
How
To add this stream, the removed code was recovered and adapted to be compatible with the current version of the code.
Recommended reading order
streams.pysource.pytest_source.pyad_direct_sponsored_contents.json
🚨 User Impact 🚨
No breaking changes, other streams were not effected, only one was added.
This change should therefore be a patch (if seen as a bug fix) or a minor change, if seen as a new feature added.
Pre-merge Actions
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.
- To see the specific tasks where the Asana app for GitHub is being used, see below:
- https://app.asana.com/0/0/1206685813413289
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| airbyte-docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jul 25, 2024 10:50am |
The endpoint was removed in https://github.com/airbytehq/airbyte/pull/26372 @artem1205 can you take a look as you made the pull request? Can you confirm this endpoint is not deprecated?
@marcosmarxm ,
Can you confirm this endpoint is not deprecated?
I can confirm that mentioned stream (endpoint) is no longer supported in Linkedin Ads. I don't see any proofs from the provided docs.
@FVidalCarneiro, Could you please provide some test results to confirm that this endpoint is still functional?
Hi @artem1205 , thank you for your time to take a look at our PR. The documentation is not at all clear regarding this endpoint, I have updated the documentation links with a more useful link, you can verify the existence of this endpoint as well through this link.
I confirm what the documentation states and therefore that the endpoint does exist and is working today. Please find below a screenshot of an example API call to the given endpoint using postman:
I have likewise tested the code with a local run on our data and the data is collected as expected, we collect multiple elements and each element has the a schema of the following example record:
{
"duration": 15000,
"aspectRatioWidth": 9.0,
"owner": "urn:li:organization:111111",
"thumbnail": "https://link.com/path",
"downloadUrlExpiresAt": 1711627200000,
"downloadUrl": "https://link-2.com/path",
"aspectRatioHeight": 16.0,
"id": "urn:li:video:5555555",
"mediaLibraryMetadata": {
"associatedAccount": "urn:li:sponsoredAccount:222222",
"mediaLibraryStatus": "ACTIVE",
"assetName": "asset-name-example.mp4"
}
@artem1205 , did you have time to verify that the endpoint exists by taking a look at my comment above ? @marcosmarxm , are there any other blockers for this PR to be merged ?
Hello @natikgadzhi , as promised, here is a description of why we need this endpoint.
Essentially, Linkedin adverts are obtained through the endpoint Linkedin Creatives. Creatives, reference some sort of content, like videos through a field called reference (more information on this on the creatives endpoint documentation). This is the field we use to make a join with the adSponsoredContent object, field content_reference. We need to make this join in order to obtain the name of the video that is associated to the Linkedin Creative we are analyzing. The adSponsoredContent is currently the only endpoint we could find that can give us the information necessary to make this join / connection.
The documentation of this adSponsoredContent object is available here.
Essentially, Linkedin adverts are obtained through the endpoint Linkedin Creatives. Creatives, reference some sort of content, like videos through a field called reference (more information on this on the creatives endpoint documentation). This is the field we use to make a join with the adSponsoredContent object, field content_reference. We need to make this join in order to obtain the name of the video that is associated to the Linkedin Creative we are analyzing. The adSponsoredContent is currently the only endpoint we could find that can give us the information necessary to make this join / connection.
The documentation of this adSponsoredContent object is available here.
Can you add this to the readme + docs for this connector? I think this will be useful for others, plus we're migrating the connector to low-code and I would love to not miss this.
Additionally, @FVidalCarneiro when we will migrate this to low code, would you like to be a reviewer on our PR? /cc @lazebnyi
@natikgadzhi , as requested, I have added documentation regarding the ad sponsored contents stream. Let me know if you want us to add more details
@FVidalCarneiro, I've kicked off the CI run on this! Thank you for continuing to work on it.
I see that formatters errored out on source_linkedin_ads/source.py - run airbyte-ci format fix all locally, or run poetry run black just for this file from the repo root.
Kicking off the CI, let's see what's going on here.
Hi @natikgadzhi , thanks, just pushed another commit to fix formatting errors (apologies for not having done it earlier). Tests seem to pass now !
@natikgadzhi , just solved the merge conflicts
I'll review the rest, but you'd need to airbyte-ci format fix all in your fork, our format-fix can't commit back to your fork ;)
@natikgadzhi , ran the formatting again, must of introduced an issue when solving merge conflicts, thanks for the heads up
Running CI @FVidalCarneiro let's wait for results.
process "python /airbyte/integration_code/main.py spec" did not complete successfully: exit code: 1
Stdout:
{"type": "LOG", "log": {"level": "FATAL", "message": "Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\nTraceback (most recent call last):\n File \"/airbyte/integration_code/main.py\", line 8, in <module>\n run()\n File \"/airbyte/integration_code/source_linkedin_ads/run.py\", line 14, in run\n launch(source, sys.argv[1:])\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 235, in launch\n for message in source_entrypoint.run(parsed_args):\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 97, in run\n source_spec: ConnectorSpecification = self.source.spec(self.logger)\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/connector.py\", line 86, in spec\n raise RuntimeError(\"Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\")\nRuntimeError: Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided."}}
{"type": "TRACE", "trace": {"type": "ERROR", "emitted_at": 1719414714121.64, "error": {"message": "Something went wrong in the connector. See the logs for more details.", "internal_message": "Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.", "stack_trace": "Traceback (most recent call last):\n File \"/airbyte/integration_code/main.py\", line 8, in <module>\n run()\n File \"/airbyte/integration_code/source_linkedin_ads/run.py\", line 14, in run\n launch(source, sys.argv[1:])\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 235, in launch\n for message in source_entrypoint.run(parsed_args):\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 97, in run\n source_spec: ConnectorSpecification = self.source.spec(self.logger)\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/connector.py\", line 86, in spec\n raise RuntimeError(\"Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\")\nRuntimeError: Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\n", "failure_type": "system_error", "stream_descriptor": null}}}
I see you've added spec.json — probably change things in spec.yaml instead.
@FVidalCarneiro here you can access the report
process "python /airbyte/integration_code/main.py spec" did not complete successfully: exit code: 1 Stdout: {"type": "LOG", "log": {"level": "FATAL", "message": "Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\nTraceback (most recent call last):\n File \"/airbyte/integration_code/main.py\", line 8, in <module>\n run()\n File \"/airbyte/integration_code/source_linkedin_ads/run.py\", line 14, in run\n launch(source, sys.argv[1:])\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 235, in launch\n for message in source_entrypoint.run(parsed_args):\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 97, in run\n source_spec: ConnectorSpecification = self.source.spec(self.logger)\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/connector.py\", line 86, in spec\n raise RuntimeError(\"Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\")\nRuntimeError: Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided."}} {"type": "TRACE", "trace": {"type": "ERROR", "emitted_at": 1719414714121.64, "error": {"message": "Something went wrong in the connector. See the logs for more details.", "internal_message": "Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.", "stack_trace": "Traceback (most recent call last):\n File \"/airbyte/integration_code/main.py\", line 8, in <module>\n run()\n File \"/airbyte/integration_code/source_linkedin_ads/run.py\", line 14, in run\n launch(source, sys.argv[1:])\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 235, in launch\n for message in source_entrypoint.run(parsed_args):\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py\", line 97, in run\n source_spec: ConnectorSpecification = self.source.spec(self.logger)\n File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/connector.py\", line 86, in spec\n raise RuntimeError(\"Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\")\nRuntimeError: Found multiple spec files in the package. Only one of spec.yaml or spec.json should be provided.\n", "failure_type": "system_error", "stream_descriptor": null}}}I see you've added spec.json — probably change things in spec.yaml instead.
Thanks @natikgadzhi , my bad, removed the spec.json file keeping the yaml file. You can go ahead and relaunch the CI
@marcosmarxm , as described by @natikgadzhi, I believe the last test is on your end to solve (regarding the sandbox account and acceptance-test-config). Could you please confirm this ? Also, I see that this PR still has your request for changes that I think we responded to, can you confirm this ?
The error is:
E Failed: High strictness level error: posts streams are declared in the catalog but do not have expected records. Please add expected records to integration_tests/expected_records.jsonl or declare these streams in empty_streams.
We need to add the expected records this stream is reading from sandbox account.
The error is:
E Failed: High strictness level error: posts streams are declared in the catalog but do not have expected records. Please add expected records to integration_tests/expected_records.jsonl or declare these streams in empty_streams.
We need to add the expected records this stream is reading from sandbox account.
@marcosmarxm , ok so do you want us to add some fictive records or will you add some from your sandbox account ?
@FVidalCarneiro I think now is up to us fix some tests requires access to Airbyte sandbox.
{"type": "RECORD", "record": {"stream": "posts", "data": {"lifecycleState": "PUBLISHED", "lastModifiedAt": 1629888842072, "visibility": "PUBLIC", "publishedAt": 1629888842026, ..., "emitted_at": 1720101201826}} {"type": "RECORD", "record": {"stream": "posts", "data": {"lifecycleState": "PUBLISHED", "lastModifiedAt": 1629665367207, "visibility": "PUBLIC", "publishedAt": 1629665367207, "author":...}, "emitted_at": 1720101202178}} {"type": "LOG", "log": {"level": "ERROR", "message": "{"code":"FORBIDDEN","message":"Accessing the resource is forbidden. Please check your permissions for this resource","status":403}"}}
@natikgadzhi, I ran these changes locally and was able to retrieve two records using OAuth. However, it fails afterward. I'm not sure if we need to update the permissions in the OAuth scope or introduce error handling in the connector code itself. Can you assist me with this? I tried to use the Token and couldn't read any records with that credential.
I found this Stack Overflow discussion about the same problem.
@marcosmarxm , just solved merge conflicts, you can re-run the CI please once the sandbox issue has been solved on your end, thanks 🙏
[!IMPORTANT]
Review skipped
Auto reviews are limited to specific labels.
Labels to auto review (1)
- coderabbit-ai-review
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai generate interesting stats about this repository and render them as a table.@coderabbitai show all the console.log statements in this repository.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@FVidalCarneiro, probably need for adapting this stream to the new low-code linkedin-ads ?