matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Update auth.py tried to solve the issue no #15871 #16352

Closed omsai11 closed 1 year ago

omsai11 commented 1 year ago

500 error when auth is null for a UIA request #15871

Pull Request Checklist

authdict = clientdict.pop("auth", {}) if "session" in authdict: sid = authdict["session"]

    # Convert the URI and method to strings.
    uri = request.uri.decode("utf-8")
    method = request.method.decode("utf-8")

    # If there's no session ID, create a new session.
    if not sid:
        new_session_data = get_new_session_data() if get_new_session_data else {}

        session = await self.store.create_ui_auth_session(
            clientdict, uri, method, description
        )

Above one is the original code:

when we put condition this: authdict = clientdict.pop("auth", {}) if "session" in authdict: sid = authdict["session"]

    # Convert the URI and method to strings.
    uri = request.uri.decode("utf-8")
    method = request.method.decode("utf-8")

    # If there's no session ID, create a new session.      // handling code 
    if not sid:
        new_session_data = get_new_session_data() if get_new_session_data else {}

        session = await self.store.create_ui_auth_session(
            clientdict, uri, method, description
        )

it will work because we are avoiding null values if it occurs it we handled by the handling code

omsai11 commented 1 year ago

Sorry actually i am a begineer and new to open source contribution thats why didnt checks

omsai11 commented 1 year ago

@clokep ok sir i will watch into it