bytebase/bytebase · error
failed to get semantic types setting
Error message
failed to get semantic types setting
What it means
buildSemanticTypeToMaskerMap could not load the semantic types setting from the store while constructing the semantic-type-to-masker map used for column classification. The store error is wrapped as 'failed to get semantic types setting'.
Source
Thrown at backend/api/v1/query_result_masker.go:158
return "Partial mask"
case *masker.MD5Masker:
return "Hash (MD5)"
case *masker.InnerOuterMasker:
// Check the actual type by examining the mask result
return "Inner/Outer mask"
default:
return "Unknown"
}
}
func buildSemanticTypeToMaskerMap(ctx context.Context, stores *store.Store) (map[string]masker.Masker, error) {
semanticTypeToMasker := map[string]masker.Masker{
"bb.default": masker.NewDefaultFullMasker(),
"bb.default-partial": masker.NewDefaultRangeMasker(),
}
semanticTypesSetting, err := stores.GetSemanticTypesSetting(ctx, common.GetWorkspaceIDFromContext(ctx))
if err != nil {
return nil, errors.Wrap(err, "failed to get semantic types setting")
}
for _, semanticType := range semanticTypesSetting.GetTypes() {
if semanticType.GetId() == "bb.default" || semanticType.GetId() == "bb.default-partial" {
// Skip the built-in default semantic types.
continue
}
m, err := getMaskerByMaskingAlgorithmAndLevel(semanticType.GetAlgorithm())
if err != nil {
return nil, err
}
// Only add semantic types that have actual masking configured (not NoneMasker)
if _, isNoneMasker := m.(*masker.NoneMasker); !isNoneMasker {
semanticTypeToMasker[semanticType.GetId()] = m
}
}
return semanticTypeToMasker, nil
}View on GitHub (pinned to 1870550677)
Solutions
- Ensure the workspace ID is set in the request context before calling query/export endpoints.
- Check metadata DB health and re-run migrations if the setting is missing.
- Re-create the semantic types setting if it was accidentally deleted.
- Retry after transient metadata DB errors.
Example fix
// before
semanticTypesSetting, err := stores.GetSemanticTypesSetting(ctx, common.GetWorkspaceIDFromContext(ctx))
if err != nil {
return nil, errors.Wrap(err, "failed to get semantic types setting")
}
// after
wsID := common.GetWorkspaceIDFromContext(ctx)
if wsID == "" {
return nil, errors.New("workspace ID not in context")
}
semanticTypesSetting, err := stores.GetSemanticTypesSetting(ctx, wsID)
if err != nil {
return nil, errors.Wrap(err, "failed to get semantic types setting")
} Defensive patterns
Strategy: try-catch
Validate before calling
wsID := common.GetWorkspaceIDFromContext(ctx)
if wsID == "" {
return errors.New("semantic types setting requires workspace context")
} Try / catch
maskers, err := buildSemanticTypeToMaskerMap(ctx, store)
if err != nil {
// retry once; then fail closed rather than returning unmasked data
} Prevention
- Ensure middleware always injects workspace ID into context.
- Do not delete or manually edit the semantic_types_setting row.
- Run all pending migrations after upgrades.
- Add health checks against the metadata DB in deployment probes.
When it happens
Trigger: stores.GetSemanticTypesSetting(ctx, common.GetWorkspaceIDFromContext(ctx)) errors; this runs whenever spanTouchesMaskedColumns or getMaskersForQuerySpan needs the map, including inside queryRetry.
Common situations: Workspace ID absent from context causing lookup failure; metadata database unavailable; semantic types setting row deleted or corrupted; incomplete migrations.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- failed to find semantic types setting
- failed to find classification setting
- failed to find masking rule policy
- failed to get maskers for query span
- failed to list databases
AI-assisted analysis of bytebase/bytebase@1870550677 (2026-09-06).
Data as JSON: /api/errors/bc059e51b0f37ee3.
Report an issue: GitHub.