You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: This PR was initially meant to add a config file cache. But for now I decided that the risk for subtle bugs caused by a stale cache was not worth the unknown benefit of caching the config
This PR speeds up the project-config test suite by replacing on-disk TOML fixture files with an in-memory filesystem (memfs), and simplifies call sites that previously passed an explicit configPath to getConfig / getRawConfig (they now rely on the default path resolution via CEDAR_CWD). The aborted config-cache work was rolled back.
config.ts: getConfig simplified — configPath is now optional (undefined passes through to getRawConfig's own default), and the double-wrapping try/catch that previously swallowed and re-threw errors from getRawConfig was correctly removed.
config.test.ts: Fixture files deleted; tests now write TOML content directly into a memfs volume keyed to /cedar-app. Env-var cleanup for API_PORT was also added. Missing vol.reset() in afterEach and no coverage for the ENOENT path.
dbAuth/api/shared.ts: getPort() refactored to a single try/catch, but this inadvertently broadens the catch to include config parse errors, silently returning 8911 instead of surfacing a malformed cedar.toml.
cli-helpers/project.ts: getConfig() called without a redundant explicit path argument.
Confidence Score: 4/5
Safe to merge once the broadened catch scope in getPort() is addressed; test improvements are non-blocking.
The core change (memfs for tests) is clean and correct. The one concrete behavioral regression is in dbAuth/shared.ts where parse errors in cedar.toml are now silently swallowed and return a default port — this affects only the development-environment error-reporting path, not serverless correctness, so the impact is limited. The two test gaps (missing vol.reset() and absent ENOENT test) are best-practice issues rather than functional bugs.
packages/auth-providers/dbAuth/api/src/shared.ts — broadened catch scope in getPort()
Important Files Changed
Filename
Overview
packages/project-config/src/config.ts
getConfig simplified: removed the try/catch wrapper (errors are now fully handled inside getRawConfig, avoiding double-wrapping) and dropped configPath default in favour of passing undefined through to getRawConfig. No cache added (intentionally, per PR description).
packages/auth-providers/dbAuth/api/src/shared.ts
getPort() simplified to a single try/catch around getConfig(), but this broadens the catch scope beyond the intended "no cedar.toml in serverless" case: a malformed config file now silently returns 8911 instead of surfacing the parse error.
packages/project-config/src/tests/config.test.ts
Tests migrated from on-disk fixture files to memfs inline JSON; API_PORT env var cleanup added. Missing vol.reset() in afterEach and the ENOENT error path is no longer explicitly tested.
packages/cli-helpers/src/lib/project.ts
updateTomlConfig simplified: getConfig() called without an explicit path (relies on CEDAR_CWD, consistent with how getConfigPath() already resolves the path just above it).
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[caller invokes getConfig] --> B{configPath provided?}
B -- yes --> C[pass configPath to getRawConfig]
B -- no --> D[getRawConfig uses default: getConfigPath]
D --> E{CEDAR_CWD set?}
E -- yes --> F[findUp cedar.toml from CEDAR_CWD]
E -- no --> G[findUp cedar.toml from process.cwd]
F --> H{file found?}
G --> H
H -- no --> I[throw: not a Cedar project]
H -- yes --> J[cache path in getConfigPathCache]
C --> K[fs.readFileSync configPath]
J --> K
K --> L{read success?}
L -- no --> M[throw: Could not parse ...]
L -- yes --> N[envInterpolation]
N --> O[toml.parse]
O --> P{parse success?}
P -- no --> M
P -- yes --> Q[merge DEFAULT_CONFIG with rawConfig]
Q --> R[return Config]
style I fill:#f88,color:#000
style M fill:#f88,color:#000
style R fill:#8f8,color:#000
Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speed up tests
Note: This PR was initially meant to add a config file cache. But for now I decided that the risk for subtle bugs caused by a stale cache was not worth the unknown benefit of caching the config