Skip to content

[Bug]: HttpPlugin overwrites server created by server_factory when specified #357

Description

Bug Description

Introduced in this PR, when instantiating an HttpPlugin with a server_factory, self._server is overwritten in a check that is only intended to ensure that the server's port and the port on the class are aligned.

Steps to Reproduce

Run this code, observe that the custom server factory is called but the server instance custom_http_plugin._server has been overwritten by this else block.

In my case, I noticed this by attempting to specify proxy_headers=False without success.

import uvicorn
from fastapi import FastAPI
from microsoft_teams.apps.http_plugin import HttpPlugin


def custom_server_factory(app: FastAPI) -> uvicorn.Server:
    print('Creating custom server!')
    return uvicorn.Server(config=uvicorn.Config(app, host='0.0.0.0', port=80, proxy_headers=False))


custom_http_plugin = HttpPlugin(server_factory=custom_server_factory)


app = App(plugins=[custom_http_plugin])

Expected Behavior

The server created by the server_factory should be used and not overwritten.

Actual Behavior

The server created by the server_factory was overwritten.

SDK Version

2.0.0a9

Python Version

3.12.3

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions