Skip to content

Comments

feat: add custom blueprint permissions configuration and management#273

Open
sellakumaran wants to merge 5 commits intomainfrom
users/sellak/customBPPermissions
Open

feat: add custom blueprint permissions configuration and management#273
sellakumaran wants to merge 5 commits intomainfrom
users/sellak/customBPPermissions

Conversation

@sellakumaran
Copy link
Contributor

@sellakumaran sellakumaran commented Feb 18, 2026

This pull request introduces comprehensive support for configuring and managing custom API permissions ("custom blueprint permissions") for agent blueprints in Agent 365. The changes add new CLI options, update documentation, and enhance integration test coverage to enable users to specify, view, and reset custom permissions for both Microsoft Graph and custom APIs. The implementation ensures validation, idempotency, and user-friendly feedback throughout the workflow.

Key changes include:

CLI Enhancements for Custom Blueprint Permissions

  • Added new options to the a365 config init command: --custom-blueprint-permissions, --resourceAppId, --scopes, --reset, and --force, allowing users to add, update, view, or clear custom API permissions directly from the CLI.
  • Implemented parameter-based logic to handle custom permissions, including validation of GUIDs and scopes, duplicate detection, and interactive confirmation for overwrites. Updated permissions are saved to both local and global config files, with context-aware next-step guidance.

Documentation Updates

  • Expanded usage instructions in Readme-Usage.md to cover custom blueprint permissions configuration, setup, and reset workflows, with CLI command examples and links to detailed guides. [1] [2]
  • Updated the design documentation to describe the new custom permissions feature, including architecture, validation, usage scenarios, and references to design docs and GitHub issue Feature Request: CLI Support for Presence & Files API Permissions #194.

Integration Test Workflow Improvements

  • Added new integration tests to integration-test-workflow.md for configuring, applying, and verifying custom blueprint permissions, including auto-lookup of resource names, Azure Portal validation, and Graph API verification of inheritable permissions. [1] [2] [3]

Other Improvements

  • Improved endpoint cleanup logging by displaying the actual endpoint name (truncated as used in Azure) during deletion preview.

These changes provide a robust and user-friendly workflow for managing custom API permissions, supporting advanced agent scenarios and improving overall configuration transparency.

Closes #194

sellakumaran and others added 3 commits February 13, 2026 16:25
…Azure Bot Service naming rules

When long hostnames (e.g., ngrok free domains) are truncated to 42 characters for Azure Bot Service,
they can end with trailing hyphens. Azure Bot Service rejects such names with InternalServerError.

Changes:
- EndpointHelper.GetEndpointName() now trims trailing hyphens after truncation
- Added input validation for null/whitespace endpoint names
- Fixed CleanupCommand to display truncated endpoint name in preview
- Added comprehensive test coverage (12 tests) including edge cases

Fixes endpoint registration failures for users with long messaging endpoint URLs.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Addresses review comment from ajmfehr on PR #257:
Changed "Please use a shorter hostname" to "Please use a longer hostname"
in the error message when endpoint name becomes too short after trimming.

Rationale: When an endpoint name becomes < 4 characters after trimming
trailing hyphens, the user needs a LONGER original hostname to compensate,
not a shorter one.

Example:
- Input: "abc----" → After trim: "abc" (3 chars, too short)
- Solution: Use longer hostname like "abcdef----" → "abcdef" (6 chars, valid)

All 12 EndpointHelper tests passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ity fixes

## Feature: Custom Blueprint Permissions
- Add support for custom API permissions in agent blueprints
- Auto-resolve resource display names from Azure (eliminates manual "Resource Name" prompt)
- New `a365 setup permissions custom` command
- New `a365 config init --custom-blueprint-permissions` management commands
- Comprehensive validation with GUID format checks and duplicate scope detection
- Integration with `a365 setup all` workflow

## Bug Fix: Graph API Error
- Fix "Agent Blueprints are not supported on the API version used" error
- Change addToRequiredResourceAccess from true to false (matches CopilotStudio/MCP pattern)
- Inheritable permissions now configure correctly without Graph API errors

## Code Quality Improvements (12 fixes from code review)
Security & Reliability:
- Add HttpResponseMessage disposal with using statements
- Add GUID validation to prevent OData injection in service principal lookups
- Add safe substring operations with null/length checks in fallback name generation
- Fix duplicate error logging when re-throwing exceptions

Maintainability:
- Add WithCustomBlueprintPermissions() helper to eliminate config reconstruction anti-pattern
- Add --force flag for non-interactive permission updates
- Add early validation for empty/whitespace scope inputs
- Fix inconsistent null handling in Scopes property with setter null protection
- Extract magic strings to constants in fallback resource names

Documentation:
- Add complete XML documentation with 10 parameter descriptions
- Remove redundant test comments
- Add trailing commas for consistency

## Files Modified
- 7 new/modified documentation files
- 12 source files (commands, models, services)
- 4 test files with 6 new unit tests

## Test Results
- ✅ 992 tests passing (6 new tests for custom permissions)
- ✅ Build: 0 warnings, 0 errors
- ✅ All critical/high priority issues resolved

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 18, 2026 16:39
@sellakumaran sellakumaran requested review from a team as code owners February 18, 2026 16:39
@github-actions
Copy link

github-actions bot commented Feb 18, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

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

This pull request introduces comprehensive support for configuring and managing custom API permissions (custom blueprint permissions) for agent blueprints in Agent 365. The feature enables users to grant additional Microsoft Graph scopes (Presence, Files, Chat) and custom API permissions beyond the standard agent operation requirements.

Changes:

  • Added new CLI options to a365 config init command for managing custom blueprint permissions with parameter-based configuration (--custom-blueprint-permissions, --resourceAppId, --scopes, --reset, --force)
  • Implemented a365 setup permissions custom subcommand with auto-lookup of resource names, validation, and integration with the existing setup workflow
  • Enhanced endpoint name handling to comply with Azure Bot Service naming constraints (42 character limit, no trailing hyphens)
  • Comprehensive test coverage including unit tests for validation, configuration, and service interactions
  • Detailed documentation covering usage, configuration, validation, error handling, and best practices

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
EndpointHelperTests.cs Tests for endpoint name truncation, hyphen trimming, and validation
GraphApiServiceTests.cs Tests for service principal display name lookup functionality
CustomResourcePermissionTests.cs Comprehensive validation tests for custom permission model
Agent365ConfigTests.cs Tests for config validation with custom permissions including duplicates
PermissionsSubcommandTests.cs Tests for custom permissions command integration
EndpointHelper.cs Enhanced endpoint name handling with validation and hyphen trimming
GraphApiService.cs Added GetServicePrincipalDisplayNameAsync with GUID validation and proper disposal
CustomResourcePermission.cs New model with validation for resource app ID, scopes, and duplicates
Agent365Config.cs Added CustomBlueprintPermissions property with validation and WithCustomBlueprintPermissions helper
SetupResults.cs Added tracking for custom permissions configuration state
SetupHelpers.cs Updated setup summary to display custom permissions status
PermissionsSubcommand.cs Implemented CreateCustomSubcommand and ConfigureCustomPermissionsAsync with auto-lookup
AllSubcommand.cs Integrated custom permissions into the setup all workflow
ConfigCommand.cs Added parameter-based custom permissions management with validation and confirmation
CleanupCommand.cs Improved endpoint cleanup logging to show actual truncated endpoint name
design.md Documented custom blueprint permissions feature architecture and usage
setup-permissions-custom.md Comprehensive command documentation with examples and troubleshooting
integration-test-workflow.md Added integration tests for custom permissions configuration and verification
Readme-Usage.md Updated usage documentation with custom permissions examples

Changed the _scopes field in CustomResourcePermission to a public Scopes property with getter and setter. The setter ensures null values are replaced with an empty list, allowing safe external access and modification of scopes.
Docs clarify that resource name is not prompted or required during `a365 config init --custom-blueprint-permissions`; it is now set to null and auto-resolved during setup. Updated sample config and validation requirements to reflect this. Minor code refactor in ConfigCommand.cs to adjust validation order.
Copilot AI review requested due to automatic review settings February 18, 2026 16:51
@sellakumaran sellakumaran enabled auto-merge (squash) February 18, 2026 16:52
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

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

using FluentAssertions;
using Microsoft.Agents.A365.DevTools.Cli.Exceptions;
using Microsoft.Agents.A365.DevTools.Cli.Services.Helpers;
using Xunit;
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The test project has global using enabled for Xunit via the project file configuration. The explicit using Xunit; statement on line 7 is redundant and should be removed to align with the codebase convention of using global usings for test frameworks.

Suggested change
using Xunit;

Copilot uses AI. Check for mistakes.

using FluentAssertions;
using Microsoft.Agents.A365.DevTools.Cli.Models;
using Xunit;
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The test project has global using enabled for Xunit via the project file configuration. The explicit using Xunit; statement on line 6 is redundant and should be removed to align with the codebase convention of using global usings for test frameworks.

Suggested change
using Xunit;

Copilot uses AI. Check for mistakes.
### Error: Invalid Permission Configuration

```
ERROR: Invalid custom permission configuration: resourceAppId must be a valid GUID, resourceName is required, At least one scope is required
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

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

The error message example is inconsistent with the actual behavior. According to the code and documentation, resourceName is optional and will be auto-resolved during setup. The error message should not include "resourceName is required". Consider updating this example to reflect the actual validation errors or add a note clarifying that this is a hypothetical example that may not reflect all actual error messages.

Suggested change
ERROR: Invalid custom permission configuration: resourceAppId must be a valid GUID, resourceName is required, At least one scope is required
ERROR: Invalid custom permission configuration: resourceAppId must be a valid GUID, At least one scope is required

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: CLI Support for Presence & Files API Permissions

1 participant