Add config store support across all adapters#209
Conversation
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Thanks for the cross-adapter config store work — the overall direction looks good. I’m requesting changes for one high-severity issue plus follow-ups.
Findings
-
High — Axum config store can expose full process environment (secret leakage risk)
crates/edgezero-adapter-axum/src/config_store.rs:12crates/edgezero-adapter-axum/src/config_store.rs:37examples/app-demo/crates/app-demo-core/src/handlers.rs:119AxumConfigStore::from_envsnapshots all env vars, so any handler pattern that accepts user-controlled keys can accidentally expose unrelated secrets.- Requested fix: replace blanket
std::env::vars()capture with an explicit allowlist (manifest-declared keys only), and avoid arbitrary key-lookup patterns in examples intended for production-like usage.
-
Medium — Adapter override key casing is inconsistent across resolution paths
crates/edgezero-core/src/manifest.rs:352crates/edgezero-macros/src/app.rs:120crates/edgezero-core/src/app.rs:59- Mixed-case adapter keys can work in one path and fail in another.
- Requested fix: normalize keys at parse/finalize time (or enforce lowercase with validation) and add a mixed-case adapter-key test.
-
Low — Missing positive-path injection coverage in adapter tests
crates/edgezero-adapter-fastly/tests/contract.rs:17crates/edgezero-adapter-cloudflare/tests/contract.rs:188- Please add success-path assertions that config store injection/retrieval works when bindings are present.
Once the high-severity item is addressed, this should be in good shape.
There was a problem hiding this comment.
Review: Config Store Feature
Overall this is a well-structured feature that follows the existing adapter pattern cleanly. The core trait, contract test macro, per-adapter implementations, and manifest/macro integration are all thoughtfully designed. Test coverage is solid across all three adapters and the docs are thorough.
That said, I found issues across four areas that should be addressed before merge — one high-severity security concern, two medium design issues, and one CI coverage gap.
Summary
| Severity | Finding |
|---|---|
| High | Axum config-store exposes entire process environment (secret leakage risk) |
| Medium | Case handling for adapter overrides is inconsistent between manifest and metadata paths |
| Medium | dispatch() bypasses config-store injection, diverging from run_app behavior |
| Medium-Low | New WASM adapter code paths are weakly exercised in CI |
See inline comments for details and suggested improvements.
ChristianPavilonis
left a comment
There was a problem hiding this comment.
Follow-up review complete. No new issues were found in the current changeset, and previously noted concerns appear addressed.
aram356
left a comment
There was a problem hiding this comment.
PR Review
Summary
Solid config store abstraction with good test coverage across all three adapters. The contract test macro and error mapping are well-designed. Main concerns are around the public dispatch API silently dropping KV handles, and a dual config resolution path that needs clarification.
Findings
Blocking
- 🔧
dispatch_with_config/dispatch_with_config_handlesilently drop KV: Both Fastly and Cloudflare versions passNonefor KV. Users migrating fromdispatchordispatch_with_kvto a config-aware path will lose KV access with no warning. (cloudflarerequest.rs:106-130, fastlyrequest.rs:78-103) - ❓ Dual config name resolution in
run_app: Both adapters checkA::config_store()(compile-time) then fall back to runtime manifest parsing. Since both derive from the sameedgezero.toml, when would these diverge? Needs documentation or removal of dead path. (cloudflarelib.rs:86-94, fastlylib.rs:97-107)
Non-blocking
- 🤔
CloudflareConfigStore::new()silent fallback: A binding typo gives an empty store with only alog::warn. Consider renaming tonew_or_empty()or removing in favor oftry_newonly. - ♻️ Duplicate bounded dedup caches: Fastly
RecentStringSetand CloudflareConfigCacheare structurally identical. Candidate for a shared core utility. - ⛏
_ctxprefix on used variable:cloudflare/tests/contract.rs:55— underscore implies unused but variable is read. - 🏕
wasm-bindgen-testin[dependencies]: Pre-existing but file was touched — test-only crate shouldn't be in production deps. - 🌱 Consider a
ConfigStoreextractor: Handlers callctx.config_store()manually; aConfigStore(store)extractor (likeKv) would complete the pattern.
📌 Out of Scope
wasm-bindgen-testdep placement should be fixed in a separate cleanup PR- Bounded cache dedup is a candidate for future core utility extraction
CI Status
- fmt: PASS
- clippy: PASS
- tests: PASS
dispatch_with_config and dispatch_with_config_handle in both the Cloudflare and Fastly adapters were passing None for the KV handle, silently dropping KV access for callers on those paths. Both now resolve the default KV binding/store (non-required) alongside the config store. Additional cleanup from review: - Document why run_app has two config-name resolution paths (macro-generated vs. manual Hooks impls) - Rename CloudflareConfigStore::new() to new_or_empty() to make the silent fallback-to-empty behavior explicit - Fix _ctx prefix on an actively-read variable in cloudflare contract tests - Move wasm-bindgen-test to [dev-dependencies]
aram356
left a comment
There was a problem hiding this comment.
PR Review
Summary
Well-structured, well-tested portable ConfigStore abstraction with implementations for Fastly, Cloudflare, and Axum. The contract test macro, security boundaries (env-var allowlisting, demo handler key allowlist), and deprecation strategy are all strong. CI passes cleanly. Two blocking issues around a silent behavioral change to ServiceUnavailable formatting and a logic bug in warning deduplication.
😃 Praise
- Contract test macro (
config_store_contract_tests!) with configurable#[$test_attr]is excellent — enableswasm_bindgen_testfor Cloudflare while others use#[test] AxumConfigStore::from_envonly reads declared keys — strong security boundary preventing the config store from becoming an env-var oracle- Demo handler allowlist (
ALLOWED_CONFIG_KEYS) — great documentation-by-example of the recommended security practice - Deprecation strategy —
dispatch()deprecated with clear migration path viadispatch_rawand new dispatch variants - CI additions — explicit
cloudflare-wasm-testsandfastly-wasm-testsjobs with properwasm-bindgen-cliversion resolution
Findings
Blocking
- 🔧
ServiceUnavailableformat string change:#[error("service unavailable: {message}")]→#[error("{message}")]removes the prefix for ALL callers, not just config store — silent behavioral change (crates/edgezero-core/src/error.rs:22) - 🔧
RecentStringSet::insertlogic bug: returnstruewithout tracking the key whenlimit == 0, defeating dedup (crates/edgezero-adapter-fastly/src/request.rs:227)
Non-blocking
- 🤔
contract_empty_key_returns_nonemay not match real Fastly behavior — realtry_get("")returnsKeyInvaliderror, notOk(None)(crates/edgezero-core/src/config_store.rs:168) - 🤔 Dispatch function proliferation — 7 dispatch-related functions per adapter; consider an options struct pattern as store types grow
- 🤔 Cloudflare
ConfigCachecachesNonefor invalid JSON permanently — correct but should document why caching failure is safe (isolate immutability) - ♻️ Duplicated bounded LRU pattern —
RecentStringSet(Fastly) andConfigCache(Cloudflare) implement the same HashMap+VecDeque eviction; extract if it appears a third time - ⛏
warned_store_cache()wrapper — function wrapping a static is unnecessary indirection; could inline inwarn_missing_store_once
📌 Out of Scope
- ❓ Spin adapter missing — PR title says "across all adapters" but Spin is excluded from
SUPPORTED_CONFIG_STORE_ADAPTERS. Consider adjusting title or creating a follow-up issue - 🌱 Spin config store support —
spin_sdk::variables::get()maps well to this abstraction; worth a follow-up issue - 📝 Cloudflare JSON-in-TOML approach — creative workaround for platform binding-name limitations; DX could be smoothed by CLI tooling generating JSON from TOML defaults
CI Status
- fmt: ✅ PASS
- clippy: ✅ PASS
- tests: ✅ PASS
- Revert #[error("{message}")] back to #[error("service unavailable: {message}")]
to restore the Display/to_string() prefix for all ServiceUnavailable callers
- Fix RecentStringSet::insert: limit==0 path returned true without tracking
the key, defeating dedup; always insert into keys/order, evict only when
limit > 0
- Document why caching None is safe in CloudflareConfigStore lookup_cached
(Cloudflare bindings are immutable within an isolate lifetime)
- Inline warned_store_cache() static into warn_missing_store_once, matching
the pattern used by warn_missing_kv_store_once
aram356
left a comment
There was a problem hiding this comment.
PR Review
Summary
This PR introduces a well-designed portable ConfigStore abstraction with implementations across Axum, Fastly, and Cloudflare adapters. The overall architecture is clean, follows established project patterns, and has solid test coverage. However, it needs a rebase onto current main to pick up the Spin adapter (#166), and there are a few gaps in CI placement and test coverage.
Praise
- 😃 Synchronous
ConfigStoretrait is the right call for all current backends — avoids unnecessary async in WASM - 😃 Contract test macro (
config_store_contract_tests!) with configurable test attribute is a great reusable pattern - 😃 Axum
from_lookupdependency injection is textbook testability design - 😃 Consistent
resolve → inject → dispatchflow across all three adapters makes the codebase easy to navigate - 😃 Cloudflare module-level docs excellently explain the JSON-in-string-binding approach with concrete examples
- 😃 Two-path config resolution comments in Fastly adapter prevent future confusion
- 😃 Feature gating (
serde_jsonbehindcloudflarefeature) is correct - 😃 Demo app handler with allowlist check, graceful degradation, and proper error propagation
- 😃 Smoke test script is well-structured with cleanup trap, readiness polling, and pass/fail summary
Findings
Blocking
- 🔧 Spin adapter missing throughout:
SUPPORTED_CONFIG_STORE_ADAPTERSinmanifest.rs:57omits"spin", andSPIN_ADAPTERconstant is missing fromapp.rs. Branch needs rebase onto main (#166). CI gate 4 (cargo check --features "fastly cloudflare spin") fails. (see inline comments) - 🔧 Cloudflare wasm check misplaced in CI:
.github/workflows/test.yml:170— the stepcargo check -p edgezero-adapter-cloudflare --features cloudflare --target wasm32-unknown-unknownis in thefastly-wasm-testsjob instead ofcloudflare-wasm-tests. If the Fastly job fails early, this check never runs. This also forces the Fastly job to installwasm32-unknown-unknownunnecessarily. Fix: Move this step to thecloudflare-wasm-testsjob. - 🔧 Missing test for store-level key miss:
handlers.rs:458—config_get_returns_404_when_key_missingtests the allowlist, notstore.get()returningNone. The store-miss code path (lines 162-165) has zero test coverage. (see inline comment)
Non-blocking
- ❓ Axum skips
A::config_store()hooks path (dev_server.rs:219): Fastly and Cloudflare use two-path resolution (compile-time hooks → manifest fallback), Axum only reads the manifest. Cross-adapter behavioral inconsistency. (see inline comment) - 🤔
contract_empty_key_returns_nonemay not hold on all backends (config_store.rs:168): Fastly Config Store SDK may error on empty keys rather than returningNone. (see inline comment) - 🤔 No convenience re-exports for config_store types (
lib.rs:6):key_value_storegetspub usere-exports butconfig_storedoesn't. (see inline comment) - 🤔
new_or_emptysilently swallows missing bindings (cloudflare/config_store.rs:37): Returns empty store with no warning when binding is missing. (see inline comment) - ♻️ Unbounded
BTreeSetin Fastly KV warn-once (fastly/request.rs:248): Config store warn-once uses boundedRecentStringSet(64 entries) but the pre-existing KV variant uses an unboundedBTreeSet. Unify on the bounded pattern. - 🏕 Missing test for
ConfigStoreError::Internalconversion (error.rs:120):UnavailableandInvalidKeycovered,Internalnot. (see inline comment) - ⛏ Test name misleading (
handlers.rs:458):config_get_returns_404_when_key_missingtests allowlist, not store miss. Consider renaming toconfig_get_returns_404_when_key_not_in_allowlist.
Out of Scope
- 📌
RecentStringSetduplicated across Fastly and Cloudflare adapters — future refactor to share in core - 📌
serve_with_listenergrew to 5 positional params — consider struct param if a third store type is added - 📌 KV adapter keys lack the same validation as config store keys (pre-existing)
- 📌 Spin adapter config store implementation (separate PR after rebase)
CI Status
- fmt: PASS
- clippy: PASS
- tests: PASS (478 tests)
- feature check (
spin): FAIL — branch needs rebase onto main
aram356
left a comment
There was a problem hiding this comment.
PR Review
Summary
Solid feature addition that introduces a portable ConfigStore abstraction following the established adapter pattern (mirrors KV store). Code is clean, well-tested (335 tests pass), and CI is green. A few items need resolution before merge.
😃 Praise
- Excellent contract test macro design with platform-specific
#[$test_attr]— ensures cross-adapter consistency while supporting WASM test frameworks - Security-conscious
AxumConfigStore::from_envthat only reads env vars for declared keys, with an explicit test provingDATABASE_URLdoesn't leak - CI upgrade splitting WASM contract tests into dedicated jobs that execute on real targets, not just compile-check
- WASM safety documentation on
std::sync::Mutexusage in Cloudflare isolates - Demo handler
ALLOWED_CONFIG_KEYSallowlist sets a good security example for users - Clean layered dispatch API in Cloudflare with clear deprecation paths
Findings
Blocking
- ❓ Axum
Hooks::config_store()asymmetry: Fastly/Cloudflare checkA::config_store()first; Axum ignores it entirely. Needs confirmation this is intentional + user-facing docs (dev_server.rs:313)
Non-blocking
- 🤔
"spin"inSUPPORTED_CONFIG_STORE_ADAPTERS: No Spin implementation exists — silent misconfiguration trap (manifest.rs:57) - 🤔
--forceonwasm-bindgen-cliinstall: Wastes ~2-3 min per CI run recompiling from source (test.yml:117) - 🤔
ConfigCache::insertis reallyget_or_insert: Method name is misleading; double-Optionreturn is subtle (cloudflare/config_store.rs:143) - ♻️ Duplicate Fastly warning helpers:
warn_missing_store_onceandwarn_missing_kv_store_onceare ~30 lines of near-identical code with inconsistent parameter types (fastly/request.rs:196-251) - ⛏ Doc comment for
ConfigStoretrait placed onConfigStoreErrorenum (core/config_store.rs:16) - ⛏ Redundant
Othermatch arm above wildcard (fastly/config_store.rs:56) - ⛏ Duplicate
node_modules/in.gitignore(line 2 and 12) - ⛏
APP_CONFIGvsapp_configcase inconsistency in docs (configuration.md:154)
🌱 Future Considerations
- No size limit on Cloudflare cached JSON payloads — platform limits mitigate this but a max-size guard could be added later
- Manual sync burden between
wrangler.toml/fastly.tomlandedgezero.tomldefaults — a futureedgezero sync-configCLI command could help
📌 Out of Scope
- Spin adapter missing from "Available Adapters" table in
docs/guide/adapters/overview.md(pre-existing gap from PR #166)
CI Status
- fmt: PASS
- clippy: PASS
- tests: PASS (335 tests)
Introduce Stores {config_store, kv, secrets} in the Axum dev server,
Fastly adapter, and Cloudflare adapter, replacing dispatch_with_handles
signatures that took 3–7 positional Option<T> arguments. Add
StoreRequirements {kv_required, secrets_required} to Fastly lib to
eliminate positional bool swap risk in run_app_with_stores.
AxumDevServer gains with_kv_handle and with_secret_handle builders,
making all three stores configurable without going through run_app.
The run_with_listener test helper is simplified to use the builders
instead of accepting a raw kv_path string.
The duplicate store_handles.rs files (identical logic, different cfg
guards) are removed; insertion is now inlined into dispatch_core_request
via the Stores struct. Also fix kv_store_name to reference
DEFAULT_KV_STORE_NAME directly, add a doc note to Spin run_app about
missing store support, log Fastly SDK lookup errors internally instead
of surfacing them in 503 responses, and document CONFIG_CACHE_LIMIT.
aram356
left a comment
There was a problem hiding this comment.
PR Review
Summary
Well-structured feature that adds a portable ConfigStore abstraction across Fastly, Cloudflare, and Axum adapters. The contract test macro, Stores struct pattern replacing positional params, and deprecation strategy for dispatch() are all well-executed. After multiple review rounds this PR is in good shape.
😃 Praise
- Contract test macro —
config_store_contract_tests!with attribute injection (#[wasm_bindgen_test]for Cloudflare,#[test]for others) is an excellent pattern that guarantees behavioral parity across backends. - Stores struct replacing positional params — Eliminates a real class of bugs (boolean/option parameter swaps).
StoreRequirementsin Fastly applies the same good idea to bool args. - Demo handler allowlist —
ALLOWED_CONFIG_KEYSplus the doc note "validate or allowlist keys first" is good security awareness and teaching. - Compile-time manifest validation — Adding
manifest.validate()in the#[app]macro catches misconfigured manifests at build time. - Comprehensive test coverage — 557 tests pass. Every adapter has contract tests, core has unit + contract tests, demo handler has 6 test cases covering happy path, missing key, no store, and unavailable store.
Findings
Non-blocking
- 🤔 Axum silently ignores
Hooks::config_store()— Fastly/Cloudflare checkA::config_store()first, Axum doesn't. Documented in a comment but creates a behavioral asymmetry. (inline comment) - ♻️
RecentStringSet::insertdouble-allocates key —key.to_string()called twice; could clone from first allocation. (inline comment) - 🏕 CF docs direct users to deprecated
run_app_with_manifest— New text at line 53 points to a deprecated function. (inline comment) - 🏕 CF docs entrypoint missing
manifest_srcarg — Pre-existing: the example showsrun_app::<App>(req, env, ctx)but the real signature takesmanifest_srcfirst. Good campsite fix since this PR adds text below it. - ⛏
Storesstruct duplicated in 3 modules — Axumdev_server.rs, Cloudflarerequest.rs, Fastlyrequest.rsdefine structurally identical structs. Fine today, worth noting if more store types are added. - 🤔 Cloudflare
lookup_cachedacquires mutex twice — Safe on single-threaded WASM, andget_or_inserthandles the TOCTOU correctly. Style observation only. - 🌱 CI cache key shared across parallel jobs — All three workflow jobs use the same cargo cache key but install different tools. Job-specific suffixes would prevent potential cache conflicts.
- 🌱 Spin config store — Correctly documented as not yet implemented. Manifest validation rejects
[stores.config.adapters.spin].
📌 Out of Scope
- Config store extractor — A dedicated
Config<T>extractor (likeValidatedJson<T>) would improve handler ergonomics but is a separate feature. - Config store write support — Current abstraction is read-only by design.
CI Status
- fmt: PASS
- clippy: PASS
- tests: PASS (557 tests)
- feature check: PASS
Summary
ConfigStoreabstraction inedgezero-corethat lets handlers read key/value configuration at runtime without coupling to a specific platform#[app]macro and each adapter's request pipeline so handlers receive aConfigStoreHandleviaRequestContextwith no boilerplateChanges
edgezero-core/src/config_store.rsConfigStoretrait,ConfigStoreHandlewrapper, and shared contract test macroedgezero-core/src/manifest.rsConfigStoreTOML binding and adapter name resolutionedgezero-core/src/context.rsconfig_store()accessor and injection helpers toRequestContextedgezero-core/src/app.rsApp::buildhooks extended to accept config store configurationedgezero-core/src/lib.rsmanifestmoduleedgezero-adapter-axum/src/config_store.rsAxumConfigStorewith defaults supportedgezero-adapter-axum/src/service.rsConfigStoreHandleinto each request before routingedgezero-adapter-axum/src/dev_server.rsDevServerConfigedgezero-adapter-axum/src/lib.rsedgezero-adapter-fastly/src/config_store.rsFastlyConfigStorebacked by Fastly edge dictionaryedgezero-adapter-fastly/src/lib.rsedgezero-adapter-fastly/src/request.rsedgezero-adapter-fastly/tests/contract.rsedgezero-adapter-cloudflare/src/config_store.rsCloudflareConfigStorebacked byworker::Envbindingsedgezero-adapter-cloudflare/src/lib.rsedgezero-adapter-cloudflare/src/request.rsedgezero-adapter-cloudflare/tests/contract.rsedgezero-macros/src/app.rs#[app]macro generates config store setup from manifestexamples/app-demo/docs/guide/scripts/smoke_test_config.sh.gitignoreCloses
Closes #51
Test plan
cargo test --workspace --all-targetscargo clippy --workspace --all-targets --all-features -- -D warningscargo check --workspace --all-targets --features "fastly cloudflare"wasm32-wasip1(Fastly) /wasm32-unknown-unknown(Cloudflare)edgezero-cli devChecklist
{id}syntax (not:id)edgezero_core(nothttpcrate)