Skip to content

Engine: inserts bypass relation-name validation, creating unreadable ghost relations #106

Closed

Description

@jsam

Summary

Schema declarations and inserts enforce relation naming inconsistently, and the result is a relation that can be written but never read.

Repro (verified on a live server, 2026-08-19)

.kg create underscore_repro
.kg use underscore_repro
+__dunder(name: string)     -- rejected: 'Relation name __dunder must start with lowercase letter'
+__dunder[("a",)]           -- ACCEPTED: 'Inserted 1 fact(s)' (auto-created, untyped: col0 any)
?__dunder(N)                -- fails: 'Cannot insert variable N - use constants only'

The insert path auto-creates the relation without running the name validation that the schema-declaration path enforces, and the query parser then cannot address the relation at all (the error message is also misleading - a query is reported as an insert problem).

Impact

This made the Python SDK's migration recorder silently broken in production use: it recorded applied migrations into inputlayer_migrations (write succeeded), but status/revert could never read them back, so showmigrations always showed unapplied and apply re-ran migrations every time. Fixed on the SDK side by renaming the relation (PR #101), but the engine should refuse the insert exactly like it refuses the declaration.

Suggested fix

Run the same relation-name validation on the insert auto-create path as on schema declarations, and fix the query error message for unaddressable relation names.

Related: the parse error for the invalid schema declaration is returned as an informational message rather than an error frame, so SDK clients cannot detect it programmatically - worth folding into the same pass.

Activity

  1. added
    bugSomething isn't working
    backendBackend/server related
    on Aug 19, 2026
  2. jsam commented on Oct 1, 2026

    @jsam
    ContributorAuthor

    Still valid at 6251065. Fixed by wp-name-validation (storage-layer grammar [a-z][a-z0-9_]*, also rejecting ':' in KG names, which currently corrupts shard ownership across tenants) and wp-parser-strings (the ? branch catches every prefix and returns a name error).

  3. added 2 commits that reference this issue on Oct 2, 2026
    21697ff
    e31751d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendBackend/server relatedbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions