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 unsupported format character 'B' #103

Merged
merged 1 commit into from May 17, 2023
Merged

Conversation

av1m
Copy link
Contributor

@av1m av1m commented May 3, 2023

I get this error : ValueError: unsupported format character 'B' (0x42) at index 61

Stacktrace :

File .venv/lib/python3.11/site-packages/pdpyras.py:1849, in APISession.iter_all(self, url, params, paginate, page_size, item_hook, total)
   1846     return
   1848 # Make the request and validate/unpack the response:
-> 1849 r = successful_response(
   1850     self.get(url, params=data.copy()),
   1851     context='classic pagination'
   1852 )
   1853 body = try_decoding(r)
   1854 results = unwrap(r, wrapper)

File .venv/lib/python3.11/site-packages/pdpyras.py:859, in successful_response(r, context)
    847 def successful_response(r: requests.Response, context=None) \
    848         -> requests.Response:
    849     """Validates the response as successful.
    850 
    851     Returns the response if it was successful; otherwise, raises an exception.
   (...)
    857     :returns: The response object, if it was successful
    858     """
--> 859     message = http_error_message(r, context=context)
...
    788         f"{endpoint}: Success (status %d) but an expectation still " \
    789         f"failed{context_msg}"
    790     )%(r.status_code)

ValueError: unsupported format character 'B' (0x42) at index 61

The actual code mix f-string and %d.
This occurs the ValueError.
I just change the code to use f-string.

Fix for 
ValueError: unsupported format character 'B' (0x42) at index 61
@allisonsuarez
Copy link

I am seeing this error too, can we get it fixed?

@alex-astronomer
Copy link

Also seeing this affecting our production environment. @Deconstrained anything I can do to get this moving?

@Deconstrained Deconstrained self-requested a review May 17, 2023 19:57
@Deconstrained Deconstrained merged commit dd2a7f0 into PagerDuty:main May 17, 2023
@Deconstrained Deconstrained mentioned this pull request May 17, 2023
@Deconstrained
Copy link
Collaborator

Thank you and pardon the late response!

@av1m
Copy link
Contributor Author

av1m commented May 17, 2023

Thank you for your approval. It would be good to update pdpyras to 5.0.2 @Deconstrained

@Deconstrained
Copy link
Collaborator

v5.0.2 which was uploaded to pypi earlier includes this fix. Afterwards I went through and found/replaced similar unsafe mixing of f-strings and printf-style strings so the generic issue is fixed and shouldn't come up again (this is in v5.0.3)

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

5 participants