MCPcopy Index your code
hub / github.com/coder/coder / parseAIProviderName

Function parseAIProviderName

coderd/searchquery/search.go:708–721  ·  view source on GitHub ↗

parseAIProviderName resolves a "provider_name" filter param against ai_providers.name. Unknown names produce a validation error so typos surface immediately rather than returning a silently-empty result set.

(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values)

Source from the content-addressed store, hash-verified

706// ai_providers.name. Unknown names produce a validation error so typos
707// surface immediately rather than returning a silently-empty result set.
708func parseAIProviderName(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values) string {
709 name := parser.String(vals, "", "provider_name")
710 if name == "" {
711 return ""
712 }
713 if _, err := db.GetAIProviderByName(ctx, name); err != nil {
714 parser.Errors = append(parser.Errors, codersdk.ValidationError{
715 Field: "provider_name",
716 Detail: `Query param "provider_name" has invalid value: provider not found or unauthorized`,
717 })
718 return ""
719 }
720 return name
721}
722
723func parseUser(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values, queryParam string, actorID uuid.UUID) uuid.UUID {
724 return httpapi.ParseCustom(parser, vals, uuid.Nil, queryParam, func(v string) (uuid.UUID, error) {

Callers 2

AIBridgeInterceptionsFunction · 0.85
AIBridgeSessionsFunction · 0.85

Calls 2

GetAIProviderByNameMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected