Skip to content

feat: dab init defaults runtime.rest.request-body-strict to false#3166

Open
Copilot wants to merge 3 commits intomainfrom
copilot/update-dab-init-defaults
Open

feat: dab init defaults runtime.rest.request-body-strict to false#3166
Copilot wants to merge 3 commits intomainfrom
copilot/update-dab-init-defaults

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Why make this change?

dab init generated configs with request-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 the RestRequestBodyStrict defaulting logic from CliBool.False ? false : true to CliBool.True ? true : false — when --rest.request-body-strict is omitted, the generated config now writes false
  • RestRuntimeOptions.cs: The record default (RequestBodyStrict = true) is preserved for backward compatibility — existing configs that omit this field continue to behave as before
  • InitOptions.cs: Updated help text to reflect (Default: false)
  • Snapshot files and hardcoded expected JSON in ConfigGeneratorTests updated to reflect the new generated default
# Before: generated config contained "request-body-strict": true
# After:
dab init --database-type mssql --connection-string "..."
# Generated config now contains: "request-body-strict": false

How was this tested?

  • Integration Tests
  • Unit Tests
    • TestRestRequestBodyStrictMode — updated DataRow for the no-flag case to assert false
    • ConfigGeneratorTests.TestSpecialCharactersInConnectionString — updated expected JSON
    • All 30 InitTests snapshots and 7 EndToEndTests snapshots (those that invoke dab init without the flag) updated to RequestBodyStrict: false
    • AddEntityTests and UpdateEntityTests snapshots intentionally unchanged — those use pre-built config strings, not dab init, and correctly reflect the record default of true

Sample Request(s)

dab init --database-type mssql --connection-string "@env('conn')"

Generated dab-config.json runtime section:

"rest": {
  "enabled": true,
  "path": "/api",
  "request-body-strict": false
}

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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>dab init to default runtime.rest.request-body-strict to false </issue_title>
<issue_description>## What?

When dab init is run, update its behavior to default runtime.rest.request-body-strict to false in the generated config. This will allow REST request bodies to accept and ignore additional fields by default, making development smoother and reducing unexpected errors.

Why?

Currently, dab init in the CLI generates a dab-config.json where the runtime.rest.request-body-strict option defaults to true (strict mode). This means all extraneous/unmapped fields in REST request bodies are rejected by default, including keys. This can cause confusion for new users and adds friction for modern scenarios where flexible request bodies are preferred, especially with C# developers.</issue_description>

<agent_instructions>Introduce as little change as possible</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Update dab init to set runtime.rest.request-body-strict to false feat: dab init defaults runtime.rest.request-body-strict to false Feb 25, 2026
@JerryNixon JerryNixon marked this pull request as ready for review February 26, 2026 05:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConfigGenerator to emit request-body-strict: false when the init flag is omitted.
  • Updated InitOptions help text and updated snapshots/CLI tests to reflect the new generated default.
  • Clarified RestRuntimeOptions documentation 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.

Comment on lines 136 to 139
// 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; }
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 12 to +14
/// <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>
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dab init to default runtime.rest.request-body-strict to false

3 participants