Находки в опенсорсе: Python
854 subscribers
4 photos
127 links
Легкие задачки в опенсорсе из мира Python

Чат: @opensource_findings_chat
Download Telegram
🚀 New issue to ag2ai/faststream by @aleksandrtikhonov
📝 Bug: missing error logs when broker initialize with argument log_level=logging.DEBUG (#2585)

Describe the bug
Missing ERROR logs when broker initialize with argument log_level=logging.DEBUG

How to reproduce
Include source code:

from faststream import FastStream
from faststream.confluent import KafkaBroker, KafkaRouter
from pydantic import BaseModel

broker = KafkaBroker("localhost:9092", log_level=logging.DEBUG)
router = KafkaRouter()
broker.include_router(router)
app = FastStream(broker)


class Suka(BaseModel):
suka_id: int


@router.subscriber("test")
async def suking(suka: Suka) -> None:
print(suka)

1. Send a message to a topic that does not match the expected model Suka.

Expected behavior
See error logs(error pydantic serializtion) in the console

Observed behavior
Error logs are missing.

Environment
faststream-0.6.0

Additional context
Provide any other relevant context or information about the problem here.

#good_first_issue #bug

sent via relator
😁12🗿3🌚2
🚀 New issue to ag2ai/faststream by @lesnik512
📝 Bug: async api route returns 500 if broker is set by set_broker (#2588)

Hi and thank you for this great framework!

Describe the bug
async api route returns 500 if broker is set by method set_broker

How to reproduce

async def test_bug() -> None:
app = faststream.asgi.AsgiFastStream(
asyncapi_path="/docs/"
)
app.set_broker(RedisBroker())

with TestClient(app=app) as test_client:
response = test_client.get("/docs/")
assert response.status_code == 500

app2 = faststream.asgi.AsgiFastStream(
RedisBroker(),
asyncapi_path="/docs/"
)

with TestClient(app=app2) as test_client:
response = test_client.get("/docs/")
assert response.status_code == 200

#bug #good_first_issue

sent via relator
🤔3
🚀 New issue to ag2ai/faststream by @lesnik512
📝 Bug: async api 3.0 errors if gssapi is used (#2593)

Describe the bug
If async api 3.0 is used with gssapi then specification is failed to render

How to reproduce

If gssapi is used for authorization for aiokafka broker then async api 3 failed to render:

Error: There are errors in your Asyncapi document
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0
Property "gssapi" is not expected to be here
0
"0" property must have required property "type"
0
"0" property must not be valid
0

Here is problematic block, as I understood

    "securitySchemes": {
"gssapi": {
"type": "gssapi"
}
}

#good_first_issue #bug

sent via relator
🚀 New issue to wemake-services/wemake-python-styleguide by @sobolevn
📝 `WPS226` false positive on fstring parts (#3548)

This code raises a violation:

x = f'single {1}'
y = f'single {1}'

When --max-string-usage=1 is provided.

Output:

  1:5      WPS226 Found string literal over-use: single  > 1
x = f'single {1}'
^


This does not seem right, because strings that are part of f strings should not be counted by WPS226

PR would be rather easy :)

#help_wanted #levelstarter #good_first_issue #bug

sent via relator
🚀 New issue to ag2ai/faststream by @carlodri
📝 LICENSE file is missing in source distribution (#2594)

Apache-2.0 requires publishing the LICENSE together with every distribution.

#good_first_issue #bug

sent via relator
🚀 New issue to ag2ai/faststream by @melenudo
📝 Bug: auto_commit is always True in Confluent Kafka (#2610)

Describe the bug

Even if you use the deprecated autocommit subscriber parameter, or if you use the ack_policy parameter with a value other than AckPolicy.ACK_FIRST, the consumer will set enable.auto.commit to True.

How to reproduce

from asyncio import sleep
from pydantic import BaseModel, Field, NonNegativeFloat

from faststream import FastStream, Logger
from faststream.confluent import KafkaBroker


class DataBasic(BaseModel):
data: NonNegativeFloat = Field(
..., examples=[0.5], description="Float data example"
)


broker = KafkaBroker("localhost:9092")
app = FastStream(broker)


@broker.publisher("output_data")
@broker.subscriber("input_data", group_id="my-group", auto_commit=False)
async def on_input_data(msg: DataBasic, logger: Logger) -> DataBasic:
logger.info(msg)
await sleep(20)
return DataBasic(data=msg.data + 1.0)


You can run this snippet (using the deprecated
auto_commit; the same behavior can be observed if you use ack_policy=AckPolicy.ACK).

In Kafka, you will notice that the message is automatically committed before
on_input_data finishes.

You can also debug the code and observe that in the consumer:

https://github.com/ag2ai/faststream/blob/8a4c60bdae02c7632c15ff1a1d15b268da6e095d/faststream/confluent/helpers/client.py#L236

self.config always has the property enable.auto.commit to True


Expected behavior
When use
@subscriber(...,ack_policy=AckPolicy.ACK) the autocommit must be disabled (same behavior for a policy different than AckPolicy.ACK_FIRST)

Observed behavior
enable.auto.commit is always True ignoring subscriber parameters.

Environment

Running FastStream 0.6.2 with CPython 3.12.9 on Darwin


#goodfirstissue #bug

sent via relator