You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Filtering on a value containing an apostrophe fails (HTTP 400) #59
Thanks for swissparlpy — we use it daily to poll Curia Vista for a Swiss financial-crime news watch, and 2.0 upgraded cleanly for us.
Reporting this here because it hits swissparlpy users even though the fix belongs upstream.
Symptom
importswissparlpyassppspp.get_data("Business", Language="FR", Title="délit d'initié")
# swissparlpy.errors.SwissParlError: The server returned a HTTP error
The generated query is:
$filter=Language eq 'FR' and Title eq 'délit d'initié'
→ HTTP 400 "Syntax error at position 45 in 'Language eq 'FR' and Title eq 'délit d'initié''."
Cause
pyodata's EdmStringTypTraits.to_literal() wraps the value in single quotes without doubling quotes inside it, so the literal terminates at the apostrophe. This affects the keyword-argument and spp.Filter paths — anything where pyodata builds the literal from a Python value. It is not a swissparlpy bug, but it bites French and Italian queries hard (l'Etat, d'initié, dell'), which is a lot of what this library is used for.
I have opened a PR upstream: SAP/python-pyodata#313. Verified against ws.parlament.ch — the same call returns HTTP 200 with the patch.
Possible action here, once upstream ships
Raise the floor to the pyodata release containing the fix (currently pyodata>=1.11.1).
Independently of that: the raw-string path is passthrough — get_data(..., filter="substringof('délit d''initié',Title)") goes straight to pyodata.filter() untouched, so escaping is the caller's job there and always will be. A line in the README, or a small exported helper (swissparlpy.escape_string()), would save the next person the 400. We carry a three-line local helper for exactly this.
Happy to send a PR for either if useful — just say which shape you would prefer.
@lefranz thank you for raising this. I agree that at the very least there should be a note about that in the README.
I'm happy if you want to provide a PR with the note and your helper method.
And re pyodata: once the fix is here, I'll update the dependency.
Activity
metaodi commentedon Aug 11, 2026
@lefranz thank you for raising this. I agree that at the very least there should be a note about that in the README.
I'm happy if you want to provide a PR with the note and your helper method.
And re
pyodata: once the fix is here, I'll update the dependency.