@service(GeocoderProvider) Fails with "No Binding Found" in LoopBack Component
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- typescript
- Área
- backend
Línea de trabajo
Comienza en la application.ts del ejemplo todo y sigue el registro de Service Booter hasta @service y filterByServiceInterface. Lee la ruta de createServiceBinding y el comportamiento propuesto de los metadatos de @serviceOptions; después, reproduce el fallo con la rama bug-no-binding-found y GET /todo. Se considera terminado cuando el GeocoderProvider sobrescrito se resuelve mediante @service sin un error No binding found.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
Problem Description
@service(GeocoderProvider) Fails with "No Binding Found" in LoopBack Component after overriding the same class via Service booter in application.
❓ Problem Statement
You created a custom LoopBack Component named DummyComponent, which declares and registers models, repositories, controllers, and a service (GeocoderProvider):
export class DummyComponent implements Component {
...
services?: ServiceOrProviderClass[];
...
constructor(
@inject(CoreBindings.APPLICATION_INSTANCE)
private application: Application,
) {
this.services = [GeocoderProvider]; // <-- Intended to register the service
}
}
and used in a controller as
export class TodoController {
constructor(
@repository(TodoRepository)
public todoRepository: TodoRepository,
@service(GeocoderProvider) // <-- This fails
protected geoService: Geocoder,
) {}
}
i added DummyComponent in application.ts as
this.component(DummyComponent);
this works fine. but when i override the GeocoderProvider via Service Booter.
this gives me error
500 Error: No binding found for GeocoderProvider.
Make sure a service binding is created in context RequestContext-xxxx with serviceInterface (GeocoderProvider).
Steps to reproduce:
- clone repo https://github.com/Tyagi-Sunny/loopback-next/tree/master
- do npm i
- move to branch bug-no-binding-found
- move to todo example in examples dir - cd examples/todo/
- run npm start
- go to http://localhost:3000
- hit GET /todo
Reason for this error->
@service decorator filters the binding based on a functions
export function filterByServiceInterface(
serviceInterface: ServiceInterface,
): BindingFilter {
return binding =>
binding.valueConstructor === serviceInterface ||
binding.tagMap[CoreTags.SERVICE_INTERFACE] === serviceInterface;
}
and if we explicitly does not provide interface then it uses class itself as interface and used it for comparison. and we end up with two different services that causes comparison to fail and returning no binding found.
As we don't have any options to provide this interface(serviceOptions) via service booter. either we need to Manually bind services after the boot process (defeating the purpose of convention-based discovery)
Solution:
I have created a decorator @serviceOptions decorator that allows you to annotate service classes with configuration options metadata. It uses the factory pattern to create decorators with a specific options metadata key.
Then createServiceBinding function is the core registration mechanism that:
- Extracts metadata: Retrieves decorator-defined options from the class
- Merges configurations: Combines decorator metadata with manually passed options (manual options take precedence)
- and rest will be same
Logs
Additional information
No response
Reproduction
https://github.com/Tyagi-Sunny/loopback-next/tree/bug-no-binding-found
- Lenguaje dominante
- TypeScript
- Estrellas
- 5.1k
- Forks
- 1.1k
- Merge medio
- 4 d 4 h
- PR fusionados (30 d)
- 44
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de loopbackio/loopback-next
-
Docs good first issue help wanted
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
loopbackio/loopback-next#683 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
loopbackio/loopback-next#11726 ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
loopbackio/loopback-next#11500 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 2 días
-
@param.array throws INVALID_PARAMETER_VALUE:must be string if more than 20 elements are sentAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
loopbackio/loopback-next#11412 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Query parameter array parsing broken for >20 items after qs upgrade (CVE fix side effect)Quizá libre de nuevo @KauanAfonso la tomó hace 126 días y no hay ningún pull request abierto. Abiertobug help wanted
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
loopbackio/loopback-next#11396 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 2 días
Todos los issues de loopbackio/loopback-next
Issues similares
-
useFragment does not require `variables` when the fragment's variables type has required fieldsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
apollographql/apollo-client#13493 ·
Los mantenedores suelen responder en 1 día
-
Custom hosts written as trailing-dot FQDNs (`host.local.`) aren't detected as local backendsPosiblemente ocupada @roboomp la tomó hoy. Abiertobug prio:p2 providers triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
can1357/oh-my-pi#15798 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
code-yeongyu/oh-my-openagent#10172 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
PDFCraftTool/pdfcraft#189 ·
-
Add the Yahoo chart API duplicate last-day row (yfinance#573) to incidents.md (about 1 hour)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertodata docs good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
pacocartones/market-data-sanity-checker#160 ·
Los mantenedores suelen responder en 1 día