Quickfix for attribution panics (#60465)

* Quickfix for attribution panics

* Return uninitialized gateway if client is nil
This commit is contained in:
Cezary Bartoszuk 2024-02-13 12:51:50 +01:00 committed by GitHub
parent 458ce56cf3
commit ac7c014b39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -81,6 +81,9 @@ func (e *enterpriseInitialization) Service() attribution.Service {
if e.endpoint == "" || e.token == "" {
return attribution.Uninitialized{}
}
if e.client == nil {
return attribution.Uninitialized{}
}
return attribution.NewGatewayProxy(e.observationCtx, e.client)
}

View File

@ -141,6 +141,9 @@ func (c *client) Attribution(ctx context.Context, snippet string, limit int) (At
return Attribution{}, err
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.accessToken))
if c.cli == nil {
return Attribution{}, errors.New("no http client")
}
resp, err := c.cli.Do(req)
if err != nil {
return Attribution{}, err