Tencent/WeKnora · error

unknown credential field: %s

Error message

unknown credential field: %s

What it means

ClearProviderCredential only supports the 'api_key' field; any other field name is rejected. This is the allowlist guard for the credential-clearing endpoint — unknown credential fields are not provider-specific parameters.

Source

Thrown at internal/application/service/web_search_provider.go:103

		return nil, fmt.Errorf("web search provider not found")
	}

	if apiKey != nil && *apiKey != "" && *apiKey != existing.Parameters.APIKey {
		existing.Parameters.APIKey = *apiKey
		if err := s.repo.Update(ctx, existing); err != nil {
			return nil, err
		}
		logger.Infof(ctx, "WebSearch provider credentials updated: tenant=%d id=%s", tenantID, id)
	}
	return existing, nil
}

// ClearProviderCredential clears the api_key credential. Idempotent.
func (s *webSearchProviderService) ClearProviderCredential(
	ctx context.Context, tenantID uint64, id, field string,
) error {
	if field != "api_key" {
		return fmt.Errorf("unknown credential field: %s", field)
	}
	existing, err := s.repo.GetByID(ctx, tenantID, id)
	if err != nil {
		return err
	}
	if existing == nil {
		return fmt.Errorf("web search provider not found")
	}
	if existing.Parameters.APIKey == "" {
		return nil
	}
	existing.Parameters.APIKey = ""
	if err := s.repo.Update(ctx, existing); err != nil {
		return err
	}
	logger.Infof(ctx, "WebSearch provider credential cleared by user: tenant=%d id=%s field=%s", tenantID, id, field)
	return nil
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Pass field="api_key" (the only clearable credential)
  2. Check the client UI sends the correct field name
  3. Extend the allowlist only if new credential fields are added
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/application/service/web_search_provider.go:103 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/041aa5e50ecd29d7. Report an issue: GitHub.