Repository navigation
fix(resource): improve YAML mapping-error suggestion for nested permissions (#12) - #17
Merged
Merged
Conversation
When an agent's frontmatter contains a granular permission block on a single line (e.g. `bash: "*": ask`), the YAML parser fails with "mapping values are not allowed in this context" and aimgr repo sync silently skips the agent. The auto-generated suggestion only mentioned quoting the description field, so users had no clue what to fix Rewrite the suggestion to cover both common causes - an unquoted ':' inside a scalar value, and a nested mapping written on the same line as its parent key - and include a corrected `permissions:` example so the fix is directly applicable Fixes dynatrace-oss#12
Contributor
Author
|
@hk9890 first PR in this repo - looks like CI needs maintainer approval to run. could you kick it off when you have a moment? no rush. thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an agent's frontmatter contains a granular permission block on a single line, like the example from #12
the YAML parser fails with
mapping values are not allowed in this context, the agent is dropped during discovery, andaimgr repo syncremoves it from the repo. The auto-generated suggestion inpkg/resource.SuggestFixonly mentioned quoting the description field, so users hit a colon-related YAML error and get advice about a field they didn't touch - the failure feels silentChange
pkg/resource.SuggestFixso it covers both common causes ofmapping values are not allowed: an unquoted:inside a scalar value, and a nested mapping written on the same line as its parent keypermissions:example so the fix is directly applicableAfter the change discovery output looks like:
Test plan
TestSuggestFixcase to assert the new wording, plus a new case that asserts the nested-mapping fix is mentionedTestRunSync_DiscoveryIssueSuggestionMentionsNestedMappingruns the full sync flow against the existing malformed-agent fixture and asserts the suggestion text reaches stdoutTestRunSync_TableOutputPrintsDiscoveryIssuesForMalformedResources,TestRunSync_JSONOutputIncludesDiscoveryIssues,TestInstallFromManifest_BootstrapPrintsDiscoveryIssuesForMalformedResourcesstill pass (the install golden-file normalizer only keeps lines containingmapping values are not allowed in this context, so the new suggestion lines don't affect it)Fixes #12