(cli): cdk flags --set always reports no template differences before applying flags

Aperta
#2,153 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@go-to-k ci sta già lavorando.

Dal 15/11/2026.

  • #2154 di @go-to-k — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
aws, typescript

Direzione di ricerca

Read packages/aws-cdk/lib/commands/flags/operations.ts, especially FlagOperations.prototypeChanges(), and trace when the app is synthesized and the context store is updated. Reproduce with the TypeScript CDK app and cdk flags --unstable=flags --set --unconfigured --recommended. Done when the preview diff includes the template changes made by the new flag values.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

cdk flags --unstable=flags --set ... (for example --unconfigured --recommended) is supposed to synthesize the app with the current flag values and with the new flag values, show the template diff between the two, and then ask for confirmation.

The diff it shows is always empty (There were no differences / Number of stacks with differences: 0), even for flags that change the template. After accepting, cdk synth shows that the template did change.

Reproduction

Confirmed with CLI 2.1145.0 / aws-cdk-lib 2.272.0.

  1. Create a project with cdk init app --language typescript
  2. Remove @aws-cdk/aws-lambda:useCdkManagedLogGroup from the context in cdk.json, and define one lambda.Function in the stack
  3. Run npx cdk flags --unstable=flags --set --unconfigured --recommended
    -> the diff says there are no differences
  4. Accept the changes and run npx cdk synth
    -> an AWS::Logs::LogGroup has been added (it is not in the synth before the change)
Expected behavior

The diff shown before the confirmation prompt includes the template changes caused by the new flag values (here, [+] AWS::Logs::LogGroup).

Root cause

FlagOperations.prototypeChanges() in packages/aws-cdk/lib/commands/flags/operations.ts:

const memoryContext = new MemoryContext(baseContextValues);
...
const source = await this.toolkit.fromCdkApp(app, {
  contextStore: memoryContext,
  outdir: this.originalTempDir,
});
...
await memoryContext.update(updateObj);
const cx = await this.toolkit.synth(source);
...
const modifiedSource = await this.toolkit.fromCdkApp(app, {
  contextStore: memoryContext,
  outdir: this.modifiedTempDir,
});
  • One MemoryContext is passed to both the "original" and the "modified" fromCdkApp() sources.
  • fromCdkApp() is lazy: the app is only synthesized, and the context store only read, at toolkit.synth(source).
  • memoryContext.update(updateObj) is called before the first synth.

So the "original" assembly is also synthesized with the new flag values, both assemblies are identical, and the diff is always empty.

Lingua principale
TypeScript
Stelle
110
Fork
138
Merge medio
1g 9h
PR unite (30g)
56

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/aws-cdk-cli

Tutte le issue di aws/aws-cdk-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.