Skip to content

fix: expandConfigStrings recurse into nested []any slices#201

Merged
intel352 merged 2 commits intomainfrom
copilot/fix-expand-config-strings-recursion
Feb 27, 2026
Merged

fix: expandConfigStrings recurse into nested []any slices#201
intel352 merged 2 commits intomainfrom
copilot/fix-expand-config-strings-recursion

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

expandConfigStrings did not recurse into []any items that are themselves []any, leaving ${VAR} placeholders unexpanded in array-of-array configs like Casbin roleAssignments.

Changes

  • engine.go: Extract []any processing into a dedicated expandConfigSlice helper that handles string, map[string]any, and []any items — enabling expansion at arbitrary nesting depth via mutual recursion with expandConfigStrings.
  • engine_secrets_test.go: Add TestExpandConfigStrings_NestedArrayOfArrays covering the []any{[]any{"${VAR}", "literal"}} pattern.
authz:
  type: authz.casbin
  config:
    roleAssignments:
      - ["${OAUTH_CLIENT_ID}", "api_client"]  # now correctly expanded

✨ 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: intel352 <77607+intel352@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix recursion for nested []any in expandConfigStrings fix: expandConfigStrings recurse into nested []any slices Feb 27, 2026
@intel352 intel352 marked this pull request as ready for review February 27, 2026 14:05
Copilot AI review requested due to automatic review settings February 27, 2026 14:05
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 PR fixes a bug where expandConfigStrings did not recurse into nested []any slices, leaving ${VAR} placeholders unexpanded in array-of-array configurations like Casbin's roleAssignments.

Changes:

  • Refactored slice expansion logic into a dedicated expandConfigSlice helper function that handles string, map, and nested array expansion via mutual recursion
  • Added comprehensive test coverage for the array-of-arrays expansion pattern

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
engine.go Extracted slice processing into expandConfigSlice helper with mutual recursion to support arbitrary nesting depth
engine_secrets_test.go Added TestExpandConfigStrings_NestedArrayOfArrays to verify expansion in nested array structures

@intel352 intel352 merged commit fe16f9e into main Feb 27, 2026
18 checks passed
@intel352 intel352 deleted the copilot/fix-expand-config-strings-recursion branch February 27, 2026 14:12
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.

3 participants