feat: dab init defaults runtime.rest.request-body-strict to false#3166
feat: dab init defaults runtime.rest.request-body-strict to false#3166
Conversation
Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates dab init config generation so newly generated configs default runtime.rest.request-body-strict to false (non-strict REST request bodies), while preserving the runtime object-model default of true for backward compatibility with existing configs that omit the field.
Changes:
- Adjusted
ConfigGeneratorto emitrequest-body-strict: falsewhen the init flag is omitted. - Updated
InitOptionshelp text and updated snapshots/CLI tests to reflect the new generated default. - Clarified
RestRuntimeOptionsdocumentation around differing defaults (existing configs vs newly generated configs).
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Config/ObjectModel/RestRuntimeOptions.cs | Updates XML docs describing RequestBodyStrict defaults/behavior. |
| src/Cli/ConfigGenerator.cs | Changes init-time defaulting to emit request-body-strict: false when omitted. |
| src/Cli/Commands/InitOptions.cs | Updates CLI help text for --rest.request-body-strict. |
| src/Cli.Tests/EndToEndTests.cs | Updates expectation for the no-flag init case to be non-strict. |
| src/Cli.Tests/ConfigGeneratorTests.cs | Updates expected generated JSON for init output. |
| src/Cli.Tests/Snapshots/* | Updates snapshots affected by init-generated default change. |
| // Since the rest.request-body-strict option does not have a default value, it is required to specify a value for this option if it is | ||
| // included in the init command. | ||
| [Option("rest.request-body-strict", Required = false, HelpText = "(Default: true) Allow extraneous fields in the request body for REST.")] | ||
| [Option("rest.request-body-strict", Required = false, HelpText = "(Default: false) Allow extraneous fields in the request body for REST.")] | ||
| public CliBool RestRequestBodyStrict { get; } |
There was a problem hiding this comment.
The CLI help text for --rest.request-body-strict is misleading given the option name/behavior: when request-body-strict is true, DAB rejects unexpected/extraneous fields (strict mode), and when false it allows them. Consider updating the HelpText (and the preceding comment) to explicitly describe the true/false semantics so users don’t interpret it as "allow" when set to true.
| /// <param name="RequestBodyStrict">Boolean property indicating whether extraneous fields are allowed in request body. | ||
| /// The default value is true - meaning we don't allow extraneous fields by default in the rest request body. | ||
| /// Changing the default value is a breaking change.</param> | ||
| /// The default value for existing configs (without this property set) is true - meaning we don't allow extraneous fields by default. | ||
| /// When dab init generates a new config, the default is false - allowing extraneous fields by default for a smoother development experience.</param> |
There was a problem hiding this comment.
The RequestBodyStrict XML doc is internally inconsistent: it says the property indicates whether extraneous fields are allowed, but then describes true as "we don't allow extraneous fields". Please reword to reflect the actual behavior (e.g., strict=true rejects extraneous/unmapped fields; strict=false ignores them) to avoid confusing readers and downstream doc generation.
Why make this change?
dab initgenerated configs withrequest-body-strict: true, causing REST endpoints to reject requests with extra/unmapped fields by default. This added friction for new users and modern scenarios where flexible request bodies are preferred.What is this change?
ConfigGenerator.cs: Changed theRestRequestBodyStrictdefaulting logic fromCliBool.False ? false : truetoCliBool.True ? true : false— when--rest.request-body-strictis omitted, the generated config now writesfalseRestRuntimeOptions.cs: The record default (RequestBodyStrict = true) is preserved for backward compatibility — existing configs that omit this field continue to behave as beforeInitOptions.cs: Updated help text to reflect(Default: false)ConfigGeneratorTestsupdated to reflect the new generated defaultHow was this tested?
TestRestRequestBodyStrictMode— updatedDataRowfor the no-flag case to assertfalseConfigGeneratorTests.TestSpecialCharactersInConnectionString— updated expected JSONInitTestssnapshots and 7EndToEndTestssnapshots (those that invokedab initwithout the flag) updated toRequestBodyStrict: falseAddEntityTestsandUpdateEntityTestssnapshots intentionally unchanged — those use pre-built config strings, notdab init, and correctly reflect the record default oftrueSample Request(s)
dab init --database-type mssql --connection-string "@env('conn')"Generated
dab-config.jsonruntime section: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 36463 --endpoint 127.0.0.1:036463 --role client --parentprocessid 4967 --telemetryoptedin false(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 36463 --endpoint 127.0.0.1:036463 --role client --parentprocessid 4967 --telemetryoptedin false(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 36463 --endpoint 127.0.0.1:036463 --role client --parentprocessid 4967 --telemetryoptedin false(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 36463 --endpoint 127.0.0.1:036463 --role client --parentprocessid 4967 --telemetryoptedin false(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.