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

Document IDs encoded server side on set, not on get #419

Open
fischer70 opened this issue Aug 9, 2023 · 0 comments
Open

Document IDs encoded server side on set, not on get #419

fischer70 opened this issue Aug 9, 2023 · 0 comments
Labels
area: python client relevant to python client bug Something isn't working triage issue to be triage

Comments

@fischer70
Copy link

Describe the bug
If a document ID contains a utf-8 character or (most) reserved characters it is percent encoded (looks like on the server side) for the document id. However, it is not on a get_document call, which means clients need to carefully encode for get_doc to work as expected.

To Reproduce

    class FakeDoc(ParentDocument):
        name: str
        _key = LexicalKey(["name"])
        aliastype: Optional[str]

    client = OpenDB()
    awfulstring = "2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm(ish)!"
    f = FakeDoc(name=awfulstring, aliatype=awfulstring)
    client.update_document(f)
    # Fails with document not found error
    try:
        client.get_document("FakeDoc/%s" % awfulstring)
    except:
        print("Nope")
    #Succeeds:
    t = client.get_document("FakeDoc/%s" % urllib.parse.quote(awfulstring, safe=",=()'!"))
    print(t)

Expected behavior
It would be kind if the client provided encoding, so that set/get on the same docid worked. Unclear exactly what encoding is going on, I merely emulated it by trial and error. IE, "()" are not encoded but "[]" are, so minimally a helper to emulate the encoding propertly would be useful.

Error logs
Here is the encoding of the awful string above:
{'@id': 'FakeDoc/2H%E2%82%82%20%2B%20O%E2%82%82%20%E2%87%8C%202H%E2%82%82O,%20R%20=%204.7%20k%CE%A9,%20%E2%8C%80%20200%20mm(ish)!', '@type': 'FakeDoc', 'name': '2H₂ + O₂ ⇌ 2H₂O, R = 4.7 kΩ, ⌀ 200 mm(ish)!'}

System information (please complete the following information):

  • OS: RHEL8 Server Ubuntu 22 client
  • terminus-client-python version = 10.2.3

Additional context
Not sure if this is actually a bug or a feature request but certainly unexpected behavior.

@fischer70 fischer70 added the bug Something isn't working label Aug 9, 2023
@github-actions github-actions bot added area: python client relevant to python client triage issue to be triage labels Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: python client relevant to python client bug Something isn't working triage issue to be triage
Projects
None yet
Development

No branches or pull requests

1 participant