Skip to content

getApplicationVariable() returns encrypted values in front components #23492

Description

@remihuigen

Description

getApplicationVariable() returns the at-rest encrypted envelope (enc:v2:...) instead of the plaintext value when called from an application front component.

This affects every application variable declared with isSecret: false. These variables are explicitly intended to be exposed to front components, so this makes the feature unusable for browser-safe configuration such as public Mapbox access tokens.

Reproduction

Define a non-secret application variable:

MAPBOX_PUBLIC_ACCESS_TOKEN: {
  universalIdentifier: getIdentifier(
    'applicationVariables',
    'mapboxPublicAccessToken',
  ),
  description: 'Client-side Mapbox access token used to render Mapbox Maps.',
  type: FieldType.TEXT,
  isSecret: false,
},

Set its value in the application settings, then use it from a front component:

import { getApplicationVariable } from 'twenty-sdk/front-component'

const token = getApplicationVariable('MAPBOX_PUBLIC_ACCESS_TOKEN')

console.log(token)

Actual behavior

token is an encrypted envelope, e.g.:

enc:v2:...

Expected behavior

token should be the plaintext configured value, e.g.:

pk.eyJ...

Secret variables must continue to be omitted entirely from front-component context.

Root cause

The front-component resolver correctly filters out variables where isSecret === true, but it forwards the encrypted database/cache value without decrypting it:

[strip-secret-from-application-variables.ts](https://github.com/twentyhq/twenty/blob/dea1f899045b6e6690724f999eb879faae977248/packages/twenty-server/src/engine/metadata-modules/front-component/utils/strip-secret-from-application-variables.ts)

acc[flatApplicationVariable.key] = String(
  flatApplicationVariable.value ?? '',
);

flatApplicationVariable.value is the persisted encrypted value. The resolver needs to decrypt non-secret application variables before serializing them into the front-component environment.

Regression

This behavior shipped with the front-component application-variable feature in twenty/v2.10.0 and remains present in v2.25.0. Strictly speaking, it is not a regression from an earlier working version of this API—the feature itself was introduced already broken.

Technical inputs

Twenty version: v2.25.0
Introduced in: twenty/v2.10.0
Introducing commit: [dea1f899045b6e6690724f999eb879faae977248](https://github.com/twentyhq/twenty/commit/dea1f899045b6e6690724f999eb879faae977248)Inject none secret env variables into front components (#20511)

Metadata

Metadata

Assignees

Labels

Type

Fields

Priority

None yet

Dev status

None yet

Start date

None yet

Target date

None yet

Quarter

None yet

Projects

Status
In project

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions