Tencent/WeKnora · error
invite code has expired
Error message
invite code has expired
What it means
The SQL validator parsed the SELECT and finished walking all clauses, but its tablesInQuery map (populated only by RangeVar table references in the FROM clause) ended up empty. This library requires every validated query to read from at least one explicitly allowed table, so table-less SELECTs are rejected as a guard against queries that only evaluate expressions or functions.
Source
Thrown at internal/application/repository/organization.go:18
package repository
import (
"context"
"errors"
"time"
"github.com/Tencent/WeKnora/internal/types"
"github.com/Tencent/WeKnora/internal/types/interfaces"
"gorm.io/gorm"
)
var (
ErrOrganizationNotFound = errors.New("organization not found")
ErrOrgMemberNotFound = errors.New("organization member not found")
ErrOrgMemberAlreadyExists = errors.New("member already exists in organization")
ErrInviteCodeNotFound = errors.New("invite code not found")
ErrInviteCodeExpired = errors.New("invite code has expired")
)
// organizationRepository implements OrganizationRepository.
//
// Plan 3 of #1303 lifts membership from per-user to per-tenant (see
// migration 000045). All "member" methods on this repo now operate on
// the (org, tenant) tuple; the underlying table is
// organization_tenant_members.
type organizationRepository struct {
db *gorm.DB
}
// NewOrganizationRepository creates a new organization repository
func NewOrganizationRepository(db *gorm.DB) interfaces.OrganizationRepository {
return &organizationRepository{db: db}
}
// Create creates a new organizationView on GitHub (pinned to 988cbb0330)
Solutions
- Add a FROM clause referencing a real (public-schema) table, e.g. `SELECT 1` becomes `SELECT 1 FROM my_table LIMIT 1` if a table read is intended.
- If the query is only a connectivity/liveness probe, bypass the validator and use the driver's native ping instead of routing it through SQL validation.
- If dynamic SQL generation dropped the FROM clause, fix the query builder/template so the table reference is always emitted.
Example fix
// before SELECT 1; // after SELECT 1 FROM users LIMIT 1;
Defensive patterns
Strategy: validation
Validate before calling
func hasFromClause(sql string) bool {
return regexp.MustCompile(`(?i)\bfrom\b`).MatchString(sql)
}
// skip validation path for pure liveness probes like "SELECT 1" Try / catch
err := validator.ValidateQuery(sql)
if err != nil && strings.Contains(err.Error(), "no valid table found") {
// route to a non-validated probe path or fix the query to include FROM
} Prevention
- Never use SELECT-expression-only queries through the validator; use a driver ping for liveness checks.
- Ensure query builders always emit a FROM clause referencing a public table.
- Add a pre-check that a FROM token with a real table name exists before calling the validator.
When it happens
Trigger: Passing a SELECT with no FROM clause (e.g. `SELECT 1`, `SELECT version()`, `SELECT now()`), or a SELECT whose FROM items were all rejected earlier (though those usually error first), through the SQL injection validator's validateSelectStmt.
Common situations: Health-check or ping queries like `SELECT 1` used by connection pools ORMs and probes; scalar expression evaluation via SELECT; dynamically generated queries where the FROM clause was accidentally omitted or template logic dropped it.
Related errors
- join request not found
- failed to retrieve: %s
- opensearch: index not found
- 2201
- opensearch: authentication failed
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/76dd96184b96116a.
Report an issue: GitHub.