Tencent/WeKnora · error
tenant api key not found
Error message
tenant api key not found
What it means
Sentinel ErrTenantAPIKeyNotFound: the tenant API-key repository looked up a key by id/value (or attempted an update/delete) and no matching row exists — either gorm.ErrRecordNotFound was mapped or the UPDATE affected 0 rows. Indicates a stale, revoked, or wrong key reference.
Source
Thrown at internal/application/repository/tenant_api_key.go:13
package repository
import (
"context"
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
)
var ErrTenantAPIKeyNotFound = errors.New("tenant api key not found")
type tenantAPIKeyRepository struct {
db *gorm.DB
}
func NewTenantAPIKeyRepository(db *gorm.DB) interfaces.TenantAPIKeyRepository {
return &tenantAPIKeyRepository{db: db}
}
func (r *tenantAPIKeyRepository) CreateAPIKey(ctx context.Context, key *types.TenantAPIKey) error {
return r.db.WithContext(ctx).Create(key).Error
}
func (r *tenantAPIKeyRepository) GetAPIKeyByHash(ctx context.Context, hash string) (*types.TenantAPIKey, error) {
var key types.TenantAPIKey
err := r.db.WithContext(ctx).Session(&gorm.Session{SkipHooks: true}).
Where("key_hash = ?", hash).
First(&key).ErrorView on GitHub (pinned to 988cbb0330)
Solutions
- Verify the API key id/value; regenerate a key if it was deleted or rotated
- Treat as 404 in the handler; do not retry the same key reference
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/application/repository/tenant_api_key.go:13 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/d59c31a619dabc07.
Report an issue: GitHub.