DAPR_* environment variables are snapshotted at import time, so loading config after import silently dials localhost
Mantenedores costumam responder em até 2 dias
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 45/100
Direção de pesquisa
Start with the dapr.conf settings module, which reads the DAPR_* variables at import, and with dapr.conf.helpers.GrpcEndpoint, which builds the endpoint from them. Run the reproduction in the issue to confirm the value stays None after os.environ changes. Done means either the settings are read when a client is constructed, or a clear error or warning is raised when os.environ and the snapshot disagree. The issue leaves the choice between these options to the maintainers, so confirm the approach before writing code.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
What happens
dapr.conf.settings reads the DAPR_* environment variables when the module is
first imported. Setting them afterwards has no effect, and the SDK silently
falls back to dns:localhost:50001 instead of the configured endpoint. There is
no warning and no error — the first symptom is a connection failure that looks
like a network or platform problem.
This is easy to hit with any of the common config patterns: python-dotenv in a
config.py, a settings module, a CLI that parses args before wiring the client,
or a framework that imports your package before your .env loader runs.
Reproduction
import os
assert "DAPR_GRPC_ENDPOINT" not in os.environ
import dapr.conf as conf
print(conf.settings.DAPR_GRPC_ENDPOINT) # None
os.environ["DAPR_GRPC_ENDPOINT"] = "https://grpc-example.example.com:443"
print(os.environ["DAPR_GRPC_ENDPOINT"]) # the value we just set
print(conf.settings.DAPR_GRPC_ENDPOINT) # None <-- still
from dapr.conf.helpers import GrpcEndpoint
ep = GrpcEndpoint(conf.settings.DAPR_GRPC_ENDPOINT
or f"localhost:{conf.settings.DAPR_GRPC_PORT}")
print(ep.endpoint) # dns:localhost:50001
Observed output:
1. imported dapr.conf with no DAPR_GRPC_ENDPOINT set
settings.DAPR_GRPC_ENDPOINT = None
settings.DAPR_GRPC_PORT = 50001
2. set DAPR_GRPC_ENDPOINT AFTER import
os.environ value = https://grpc-example.example.com:443
settings.DAPR_GRPC_ENDPOINT = None
3. endpoint the SDK would dial: dns:localhost:50001
Expected
Any of the following would have saved the debugging time:
- Read the setting lazily, at client construction, rather than at import.
- Keep the import-time read, but re-check
os.environwhen a client is built
and raise or warn on a mismatch betweenos.environ["DAPR_GRPC_ENDPOINT"]
andsettings.DAPR_GRPC_ENDPOINT. - Document it prominently in the client docs — "set
DAPR_*before importing
dapr" — since the current failure mode is silent.
(1) seems best; (2) is the cheapest thing that makes the failure loud.
Environment
dapr1.18.3,dapr-ext-workflow1.18.3- Python 3.12.12, macOS 15 (darwin 24.3.0)
- Talking to a managed Dapr control plane over a remote gRPC endpoint, so the
localhost fallback can never succeed
Why it matters
Against a local sidecar the fallback is often correct, which is why this is
rarely noticed. Against any remote or managed endpoint it is always wrong, and
the error surfaces far from its cause — the one I chased presented as "every
connection fails", with correct-looking values in .env and in os.environ.
- Linguagem predominante
- Python
- Estrelas
- 274
- Forks
- 157
- Merge médio
- 5d 15h
- PRs com merge (30d)
- 70
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de dapr/python-sdk
-
SDK Alignment of Workflow ExamplesTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertadapr-ext-workflow good first issue kind/enhancement P2
Dificuldade 2/5 1-2 dias Facilidade para iniciantes 72/100
dapr/python-sdk#853 · 4 comentários ·
Mantenedores costumam responder em até 2 dias
-
ci/release-failure release
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 49/100
dapr/python-sdk#1311 ·
Mantenedores costumam responder em até 2 dias
-
help wanted kind/enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
dapr/python-sdk#1296 ·
Mantenedores costumam responder em até 2 dias
-
[WORKFLOW SDK FEATURE REQUEST] Retry WaitForInstanceCompletion/Start on a server-sent CANCELLEDAbertadapr-ext-workflow kind/enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
dapr/python-sdk#1246 ·
Mantenedores costumam responder em até 2 dias
-
[BUG] subscribe_with_handler stops silently: async task can die or be collected, sync retry path exits, handler errors reconnect the streamTalvez já em andamento @CasperGN assumiu há 25 dias. Abertakind/bug
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 65/100
dapr/python-sdk#1233 ·
Mantenedores costumam responder em até 2 dias
Todas as issues de dapr/python-sdk
Issues semelhantes
-
Use mhctools predictor_required=False for saved-result rescoringTalvez já em andamento @iskandr assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 79/100
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
521xueweihan/HelloGitHub#4051 · 1 comentário ·
-
bug documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
awslabs/visual-asset-management-system#514 ·
Mantenedores costumam responder em até 1 dia
-
backend bug spec:REQ-053
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
nolte/kamerplanter#2547 ·
Mantenedores costumam responder em até 1 dia