Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

Why make this change?

Implements CLI command to configure autoentities definitions via command line. Previously, users had to manually edit the config file to add or modify autoentities entries.

What is this change?

Added autoentities-configure command that upserts autoentities definitions with support for:

  • Pattern matching rules (--patterns.include, --patterns.exclude, --patterns.name)
  • Template configuration for REST, GraphQL, MCP, Health, Cache endpoints
  • Permissions using standard role:actions format

Implementation:

  • AutoentitiesConfigureOptions.cs - Command options class following existing CLI patterns
  • ConfigGenerator.TryConfigureAutoentities() - Main handler with builder methods for patterns, template, and permissions
  • Registered command in Program.cs parser

Bug fixes:

  • AutoentityConverter and AutoentityTemplateConverter - Added missing MCP options serialization logic that prevented MCP settings from persisting to config file
  • AutoentityTemplateConverter - Fixed GraphQL template serialization to only write enabled property, excluding type object (singular/plural) which is determined by generated entities

Improvements:

  • Enhanced error messages to display all valid parameter values using EnumExtensions.GenerateMessageForInvalidInput<T>() pattern
  • Cache level errors now show: "Invalid Source Type: {value}. Valid values are: L1,L1L2"
  • MCP dml-tool errors now show: "Invalid value for template.mcp.dml-tool: {value}. Valid values are: true, false"
  • Permissions validation: Added runtime validation that requires --permissions only when creating a new autoentity definition. When updating an existing definition, permissions are optional and preserved from the existing configuration.

How was this tested?

  • Unit Tests
  • Integration Tests

Added 8 unit tests covering:

  • Create/update operations with patterns and template options
  • Permission parsing with multiple actions
  • Error handling for invalid enum values
  • Multiple coexisting definitions
  • Permissions validation for new vs. existing definitions

Sample Request(s)

# Create new definition with patterns and permissions (permissions required for new definitions)
dab autoentities-configure my-def \
  --patterns.include "dbo.%" "sys.%" \
  --patterns.exclude "dbo.internal%" \
  --patterns.name "{schema}_{table}" \
  --permissions "anonymous:read"

# Configure template options (GraphQL now only writes 'enabled', not 'type')
dab autoentities-configure my-def \
  --template.rest.enabled true \
  --template.graphql.enabled true \
  --template.cache.enabled true \
  --template.cache.ttl-seconds 30 \
  --template.cache.level L1L2

# Update existing definition without permissions (permissions optional for updates)
dab autoentities-configure my-def \
  --template.mcp.dml-tool false \
  --template.cache.ttl-seconds 60

Result in config:

{
  "autoentities": {
    "my-def": {
      "patterns": {
        "include": ["dbo.%", "sys.%"],
        "exclude": ["dbo.internal%"],
        "name": "{schema}_{table}"
      },
      "template": {
        "rest": { "enabled": true },
        "graphql": { "enabled": true },
        "mcp": false,
        "cache": {
          "enabled": true,
          "ttl-seconds": 60,
          "level": "l1l2"
        }
      },
      "permissions": [
        {
          "role": "anonymous",
          "actions": [
            { "action": "read" }
          ]
        }
      ]
    }
  }
}

Notes:

  • GraphQL template now correctly serializes as "graphql": { "enabled": true } without the empty type object that was previously being written.
  • Permissions are required when creating new autoentity definitions but optional when updating existing ones.
Original prompt

This section details on the original issue you should resolve

<issue_title>Add CLI command dab autoentities configure</issue_title>
<issue_description>New CLI commands need to be added in order to allow the users to change the autoentities properties inside of the config file.
Introduce a new autoentities configure subcommand that operates like an upsert.
These commands need to follow the existing coding pattern that we have for the other CLI commands

dab autoentities configure {definition-name} --patterns.include value
dab autoentities configure {definition-name} --patterns.exclude value
dab autoentities configure {definition-name} --patterns.name value

dab autoentities configure {definition-name} --template.mcp.dml-tool value
dab autoentities configure {definition-name} --template.rest.enabled value
dab autoentities configure {definition-name} --template.graphql.enabled value
dab autoentities configure {definition-name} --template.cache.enabled value
dab autoentities configure {definition-name} --template.cache.ttl-seconds value
dab autoentities configure {definition-name} --template.cache.level value
dab autoentities configure {definition-name} --template.health.enabled value

dab autoentities configure {definition-name} --permissions role:actions
```</issue_description>

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

<comments>
</comments>


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

Copilot AI and others added 3 commits January 30, 2026 20:14
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CLI command dab autoentities configure Add CLI command dab autoentities-configure Jan 30, 2026
/// AutoentitiesConfigureOptions command options
/// This command will be used to configure autoentities definitions in the config file.
/// </summary>
[Verb("autoentities-configure", isDefault: false, HelpText = "Configure autoentities definitions", Hidden = false)]
Copy link
Contributor

Choose a reason for hiding this comment

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

The command should be autoentities configure, it should not have a - symbol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The CommandLine library we're using doesn't support spaces in verb names natively. Using "autoentities configure" as the verb name results in parsing errors. The current implementation with autoentities-configure follows the same pattern as the existing add-telemetry command.

To support true nested commands like dab autoentities configure, we would need to implement custom command parsing logic, which would be a significant refactor of how the CLI handles commands.

Would you like me to implement custom nested command support, or is the current autoentities-configure approach acceptable given the technical constraints?

Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is that it should be two different commands, first would be autoentities and as a subcommand from autoentities we should have configure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand you want dab autoentities configure as nested commands. The CommandLineParser library we're using doesn't natively support multi-level verb hierarchies (parent verb + subcommand pattern).

To implement this would require:

  1. Custom argument preprocessing to detect "autoentities" and route to subcommand parsing
  2. Manual parsing of the second verb ("configure")
  3. Restructuring how all commands are registered and invoked

This is a significant architectural change that would affect the core CLI parsing logic in Program.cs. The current autoentities-configure approach (single verb with dash) follows the same pattern as add-telemetry and works with the existing CommandLineParser infrastructure.

Would you like me to implement the custom nested command parsing, or should we proceed with the current single-verb approach?

- Fix GraphQL template to only serialize 'enabled' property (not 'type')
- Improve error messages to show all valid parameter values
- Use EnumExtensions.GenerateMessageForInvalidInput for EntityCacheLevel
- Update MCP dml-tool error message to show valid values

Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
/// AutoentitiesConfigureOptions command options
/// This command will be used to configure autoentities definitions in the config file.
/// </summary>
[Verb("autoentities-configure", isDefault: false, HelpText = "Configure autoentities definitions", Hidden = false)]
Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is that it should be two different commands, first would be autoentities and as a subcommand from autoentities we should have configure.

- Require permissions when creating a new autoentity definition
- Allow updating existing definitions without providing permissions
- Improve error handling to distinguish between parsing failure and missing permissions

Co-authored-by: RubenCerna2079 <32799214+RubenCerna2079@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CLI command dab autoentities configure

2 participants