Add missing level property to entity cache schema
#3097
+6
−0
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.
Why make this change?
The
levelproperty for entity caching is fully implemented in the codebase (EntityCacheOptions, converters, runtime service) but missing from the JSON schema, causing validation warnings in IDEs anddab validatedespite the property working correctly at runtime.What is this change?
Added
levelproperty definition to entity cache section inschemas/dab.draft.schema.json(lines 1123-1128), matching the existing template cache section:Modified Files:
schemas/dab.draft.schema.json(+6 lines)Schema now validates cache level configurations:
L1: In-memory cache only (single-instance)L1L2: In-memory + distributed cache (multi-instance with Redis)How was this tested?
All 49 cache configuration tests pass. Schema validation tests pass. Manual validation confirms proper acceptance of valid values (
L1,L1L2) and rejection of invalid values.Sample Request(s)
Entity configuration with cache level now validates correctly:
{ "entities": { "Book": { "source": { "object": "books", "type": "table" }, "cache": { "enabled": true, "ttl-seconds": 10, "level": "L1" }, "permissions": [...] } } }Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
azuread/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.deps.json /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/testhost.dll --port 43477 --endpoint 127.0.0.1:043477 --role client --parentprocessid 4776 --telemetryoptedin false ns.cs ndor/bin/grep grep(dns block)custom/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.deps.json /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/testhost.dll --port 43477 --endpoint 127.0.0.1:043477 --role client --parentprocessid 4776 --telemetryoptedin false ns.cs ndor/bin/grep grep(dns block)entraid/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.deps.json /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/testhost.dll --port 43477 --endpoint 127.0.0.1:043477 --role client --parentprocessid 4776 --telemetryoptedin false ns.cs ndor/bin/grep grep(dns block)xxxxx/usr/share/dotnet/dotnet /usr/share/dotnet/dotnet exec --runtimeconfig /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.runtimeconfig.json --depsfile /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/Cli.Tests.deps.json /home/REDACTED/work/data-api-builder/data-api-builder/src/out/tests/net8.0/testhost.dll --port 43477 --endpoint 127.0.0.1:043477 --role client --parentprocessid 4776 --telemetryoptedin false ns.cs ndor/bin/grep grep(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
This section details on the original issue you should resolve
<issue_title>Missing
levelsection in entities property</issue_title><issue_description>The entities property inside of the schema file is missing the
levelsection for caching. Everything else related to this feature is already implemented, so it is only necessary to add thelevelproperty to the schema file and ensure to add tests related to this property if they are missing.</issue_description><agent_instructions>Fix with as little new code as possible</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@JerryNixon ### Current StateThe
levelproperty for entity caching is already fully implemented in the code, but it's missing from the JSON schema file (schemas/dab.draft.schema.json) that validates DAB configuration files.What Already Works
Looking at the code, the
levelproperty is:What's Missing
The JSON schema file does include
levelin the template section but NOT in the main entity cache configuration:This is only in the template section. The main entities schema likely needs the same property added.
How It Should Be Used
{ "entities": { "Book": { "source": { "object": "books", "type": "table" }, "cache": { "enabled": true, "ttl-seconds": 10, "level": "L1" // ← This is the missing property in schema validation } } } }Cache levels:
L1: In-memory cache only (faster, but not shared across instances)L1L2(default): In-memory + distributed cache (Redis) for multi-instance scenariosWorkarounds
Since the functionality already works in the runtime but the schema validation might complain:
1. Just Use It (Recommended)
You can add the
levelproperty to your configuration file even if the schema doesn't validate it:{ "entities": { "MyEntity": { "cache": { "enabled": true, "ttl-seconds": 30, "level": "L1" } } } }DAB will read and honor it because the code implementation exists. The only downside is:
dab validatecommand might complain2. Ignore Schema Validation Warnings
If you're using VS Code or another editor with JSON schema validation:
levelpro...levelsection in entities property #2981✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.