Skip to content

config.d.ts union type precedence bug causes config validation failure for dynatrace.environments #331

Open

Description

@oscarstep

Summary

The TypeScript union type definition for environments in plugins/dql-backend/config.d.ts has incorrect operator precedence, causing Backstage's config schema compiler to generate an object type instead of an array type. This makes the app fail to start with a config validation error when using the documented array format for dynatrace.environments.

Expected Behavior

Backstage should start successfully when dynatrace.environments is configured as an array, as shown in the plugin's own README documentation:

dynatrace:
  environments:
    - name: xxxxxxxx
      url: https://xxxxxxxx.apps.dynatrace.com
      tokenUrl: https://sso.dynatrace.com/sso/oauth2/token
      accountUrn: <accountUrn>
      clientId: <clientId>
      clientSecret: <clientSecret>

Current Behavior

Backstage fails to start with the following error:

Plugin 'app' threw an error during startup. Invalid app bundle schema.
Caused by: Config validation failed, Config must be object { type=object } at /dynatrace/environments

Steps to Reproduce

  1. Install @dynatrace/backstage-plugin-dql-backend v2.6.0
  2. Configure dynatrace.environments as an array in app-config.yaml (following the README)
  3. Build the app with yarn --cwd packages/app build
  4. Start the backend

Possible Solution

The issue is in plugins/dql-backend/config.d.ts 19. The current type:

environments:
    { /* OAuthConfig */ } | { /* TokenConfig */ }[],

Due to TypeScript operator precedence, this is parsed as OAuthConfig | (TokenConfig[]) — a union of a single object or an array. Backstage's config schema compiler picks the first branch (object) and generates { type: "object" } for the JSON schema.

The fix is to wrap the union in parentheses so the array applies to both types:

environments:
    ({ /* OAuthConfig */ } | { /* TokenConfig */ })[],

This makes it unambiguously (OAuthConfig | TokenConfig)[] — an array of either type, which matches the documented config format.

Context

This prevents deploying Backstage with the Dynatrace DQL plugin in any environment where the app bundle is built.
The error occurs in @backstage/plugin-app-backend at readFrontendConfig.cjs.js:26 during config schema validation against the compiled app bundle.

Your Environment

  • @dynatrace/backstage-plugin-dql-backend version: 2.6.0
  • @dynatrace/backstage-plugin-dql version: 2.6.0

Metadata

Metadata

Assignees

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