Skip to content

fix(cdn): reject manifests missing artifacts before cache wipe#2288

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-remediation-c80c
Draft

fix(cdn): reject manifests missing artifacts before cache wipe#2288
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-remediation-c80c

Conversation

@cursor

@cursor cursor Bot commented Jun 17, 2026

Copy link
Copy Markdown

Bug and impact

Trigger: A CDN-backed app with a working cached manifest runs a background refresh (_refreshIfStale). The manifest download returns HTTP 200 with JSON that parses successfully but has no artifacts section (bad deploy, CDN misconfiguration, or a truncated body like {}).

Impact: _rebuildFromRoot() cleared all in-memory screens, translations, theme, and secrets before discovering artifacts was missing, then returned early. _doRefreshIfStale() still persisted the unusable manifest to SharedPreferences. The app could lose all definitions for the rest of the session and on subsequent cold starts until a valid manifest was published.

Root cause

_rebuildFromRoot() mutated cache state (clearing _artifactCache, mappings, config, and runtime secrets) before validating that the manifest contained an artifacts map. When validation failed, it returned without restoring the previous cache.

Fix

  • Validate that artifacts exists before any cache mutation in _rebuildFromRoot().
  • Throw ConfigError on invalid manifests so refresh callers skip _saveCachedState() and retain the last good in-memory definitions.
  • Added a regression test asserting an invalid rebuild throws and does not wipe loaded translations.

Validation

  • Added modules/ensemble/test/cdn_provider_test.dart coverage for manifests missing artifacts.
  • Run from modules/ensemble: flutter test test/cdn_provider_test.dart
  • Flutter SDK was not available in the automation environment; please verify in CI.

Duplicate check

Open in Web View Automation 

Background CDN refresh called _rebuildFromRoot() which cleared all
in-memory definitions before checking for an artifacts section. A
transient or bad deploy returning parseable JSON without artifacts
(e.g. {}) wiped the working session and could persist the unusable
manifest via _saveCachedState.

Validate the artifacts section exists before mutating cache state so
failed refreshes keep the last good definitions.

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant