Skip to content

[BUG] Excluded models still exposed via relations in slicing #2628

@Jamie-Fairweather

Description

@Jamie-Fairweather

Description and expected behavior

When using QueryOptions slicing.includedModels / excludedModels, relational fields referencing excluded models are still exposed in both:

  1. The runtime API response
  2. The generated OpenAPI schema

Scenario

Given two models: Link and Workspace

I configure slicing to include Link but explicitly exclude Workspace:

const queryOptions: QueryOptions<SchemaType> = {
    slicing: {
        includedModels: ['Link', 'TargetingRule', 'Campaign', 'ClickEvent', 'Domain'],
        excludedModels: ['Workspace'],
    },
};

...

private readonly handler = new RPCApiHandler({ schema, queryOptions })

Observed behavior

  • The Link model still exposes:
    • workspaceId
    • workspace (relation)
  • These fields:
    • Appear in OpenAPI schema
    • Are present in runtime responses
    • Can even be explicitly populated via include

Expected behavior

When a model is excluded via slicing:

  • All references to that model should be fully removed, including:
    • Foreign keys (workspaceId)
    • Relation fields (workspace)
  • These fields should:
    • Not appear in OpenAPI at all
    • Not be queryable via include

Screenshots

1. IDE autocomplete for omit does not provide options to exclude relational fields like workspace or workspaceId

Image

2. OpenAPI schema still includes workspace and workspaceId

Image

3. Runtime API response includes workspaceId even when Workspace is excluded

Image

4. Runtime API response includes workspace when configured via the include param

Image

Environment (please complete the following information):

  • ZenStack version: 3.6.3
  • Database type: Postgresql
  • Bun version: 1.3.12
  • Package manager: Bun

Additional context

  • This appears to affect both:
    • OpenAPI generation
    • Runtime query enforcement
  • It is currently possible to bypass the exclusion by explicitly adding the relation to include
  • The omit configuration does not surface relational fields, which makes it impossible to manually work around this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions