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

fix(javascript): do not send user-agent for Predict #919

Merged
merged 1 commit into from
Aug 11, 2022

Conversation

shortcuts
Copy link
Member

@shortcuts shortcuts commented Aug 10, 2022

🧭 What and Why

🎟 JIRA Ticket: https://algolia.atlassian.net/browse/APIC-621

See https://algolia.atlassian.net/browse/PRED-523 for context

Changes included:

The Predict API does not yet support user-agent query parameters, which makes every requests being rejected for unknown/non-parsable query parameter.

This is a not-really-pretty patch until it gets implemented, I've tried to minimize the footprint on the other clients but they all use the same requester. LMK if you have alternatives.

  • JavaScript: We now send an empty string to the factory, which is not forwarded by the transporter.
  • Tests: Small condition to skip the generation of the user-agent test for the Predict client.

I've added the Jira ticket in a comment near the patches until it gets resolved, to avoid forgetting to remove it.

The fix is only applied for JavaScript, as it's the only client that is recommended from the Predict team.

🧪 Test

yarn docker playground javascript predict should show an empty algoliaAgent, which gets removed if you do a real request (screenshot is with the echoRequester)

Screenshot 2022-08-10 at 18 46 48

@netlify
Copy link

netlify bot commented Aug 10, 2022

Deploy Preview for api-clients-automation canceled.

Name Link
🔨 Latest commit f9dcb5a
🔍 Latest deploy log https://app.netlify.com/sites/api-clients-automation/deploys/62f3df8bd50a8600083937c1

@algolia-bot
Copy link
Collaborator

algolia-bot commented Aug 10, 2022

✗ The generated branch has been deleted.

If the PR has been merged, you can check the generated code on the main branch.
You can still access the code generated on main via this commit.

Comment on lines +118 to +121
if (algoliaAgent.value) {
queryParameters['x-algolia-agent'] = algoliaAgent.value;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only part that impacts the other client, which is something we are in control of as it's only reached by the factory of each clients.

@shortcuts shortcuts enabled auto-merge (squash) August 10, 2022 16:52
Copy link
Contributor

@damcou damcou left a comment

Choose a reason for hiding this comment

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

LGTM, do we know when the Predict client will accept user-agent ?

@shortcuts
Copy link
Member Author

LGTM, do we know when the Predict client will accept user-agent ?

their engineers are OOO so the issue should be tackled once they come back

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.

None yet

3 participants