-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 Facebook Marketing: fix unpack ValueError in remove_params_from_url #5758
🐛 Source Facebook Marketing: fix unpack ValueError in remove_params_from_url #5758
Conversation
…move params from url
/test connector=source-facebook-marketing
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should use more generic solution
if len(q.split("=")) == 2: | ||
key, value = q.split("=") | ||
if key not in params: | ||
res_query.append(f"{key}={value}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from urllib.parse import urlparse, parse_qs, urlunparse, urlencode
def remove_params_from_url(url, params):
"""
>>> remove_params_from_url('https://foo.bar/?x=1&y=&z=3', params=['x'])
'https://foo.bar/?y=&z=3'
>>> remove_params_from_url('https://foo.bar/?x=1&y=&z=3', params=['y'])
'https://foo.bar/?x=1&z=3'
>>> remove_params_from_url('https://foo.bar/?x=1&y=&z=3', params=['x', 'z'])
'https://foo.bar/?y='
>>> remove_params_from_url('https://foo.bar/?x=1&y=&z=3&x=111', params=['z'])
'https://foo.bar/?x=1&x=111&y='
"""
parsed = urlparse(url)
query = parse_qs(parsed.query, keep_blank_values=True)
filtered = dict((k, v) for k, v in query.items() if k not in params)
return urlunparse([
parsed.scheme,
parsed.netloc,
parsed.path,
parsed.params,
urlencode(filtered, doseq=True),
parsed.fragment
])
It was fixed in PR #5958 |
What
According to comment in issue #5190 jobs are failing in
streams.remove_params_from_url
:remove_params_from_url
method is used while syncing ad creatives streams. Its records contains thumbnail url, which have query parameters. Some URLs has random values, these values doesn't affect validity of URLs, but breaks SAT, therefore parameters with this values are removed. Error occurred when parameters didn't have values. Additional checking was added.