Skip to content

Consistently escape function metadata identifiers in .fx.yaml - #819

Merged
Crash Collison (tehcrashxor) merged 2 commits into
masterfrom
joshuac-microsoft-escape-arg-metadata-identifier
Oct 13, 2026
Merged

Crash Collison (tehcrashxor) merged 2 commits into
masterfrom
joshuac-microsoft-escape-arg-metadata-identifier

Conversation

@tehcrashxor

@tehcrashxor Crash Collison (tehcrashxor) commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Problem

Identifiers in function argument metadata blocks weren't escaped when written to .fx.yaml, unlike other identifiers (control, property, function and parameter names). Some names containing special characters weren't written correctly and didn't round-trip between unpack and pack.

Solution

Escape these identifiers on write and unescape them on read, the same way as other identifiers. Also harden YamlWriter so it rejects property names it can't represent.

Changes

  • PAWriterVisitor: function argument metadata keys are written with CharacterUtils.EscapeName.
  • Parser.ParseArgMetadataBlock: keys are read with CharacterUtils.UnEscapeName. Simple identifiers are written exactly as before, so existing .fx.yaml files are unaffected.
  • CharacterUtils.UnEscapeName: reports a parse error for an empty identifier (including escaped forms such as '') instead of throwing IndexOutOfRangeException or returning an empty name.
  • YamlWriter: WriteStartObject and the WriteProperty overloads throw ArgumentException for property names containing any line terminator recognized by CharacterUtils.IsLineTerm.
  • Tests: new PAWriterVisitorTests (round-trip of simple and escaped identifiers, line breaks rejected, empty identifiers report an error) and YamlTest.WriteRejectsLineBreaksInPropertyNames.

Validation

  • dotnet build src\PASopa.sln: succeeded, 0 warnings, 0 errors.
  • dotnet test --no-build --project src\PAModelTests\PAModelTests.csproj: passed on net8.0, net10.0 and net48 (873 total, 0 failed).
  • With the product changes reverted, the new test cases covering the changed behavior fail.

Function argument metadata keys are now escaped on write and unescaped on read, matching how other identifiers are handled. YamlWriter also rejects property names containing line breaks, which can't round-trip.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tehcrashxor
Crash Collison (tehcrashxor) force-pushed the joshuac-microsoft-escape-arg-metadata-identifier branch from dc07954 to 05c39a5 Compare October 13, 2026 22:18
@tehcrashxor Crash Collison (tehcrashxor) changed the title Escape function arg metadata identifiers when writing .fx.yaml Consistently escape function metadata identifiers in .fx.yaml Oct 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Escaped empty identifiers remain accepted, and several YAML line terminators bypass the new validation.

2 open findings
What changed in this PR

Updates the legacy PAModel .fx.yaml pipeline to round-trip escaped function metadata identifiers and reject unsupported property names.

Changes:

  • Escapes metadata keys during writing and unescapes them during parsing.
  • Adds property-name validation and empty-identifier handling.
  • Adds round-trip and validation tests.
File Description
src/​PAModelTests/​YamlTest.cs Tests property-name rejection.
src/​PAModelTests/​PAWriterVisitorTests.cs Tests metadata identifier round-tripping and errors.
src/​PAModel/​PAConvert/​Yaml/​YamlWriter.cs Validates property names before writing.
src/​PAModel/​PAConvert/​PAWriterVisitor.cs Escapes metadata identifiers.
src/​PAModel/​PAConvert/​Parser/​Parser.cs Unescapes metadata identifiers.
src/​PAModel/​PAConvert/​Parser/​CharacterUtils.cs Handles raw empty identifiers.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/PAModel/PAConvert/Parser/CharacterUtils.cs
Comment thread src/PAModel/PAConvert/Yaml/YamlWriter.cs Outdated
Reject escaped identifiers that decode to an empty name, and reject all line terminators recognized by CharacterUtils.IsLineTerm in YAML property names.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tehcrashxor
Crash Collison (tehcrashxor) merged commit 8fb6bbf into master Oct 13, 2026
6 checks passed
@tehcrashxor
Crash Collison (tehcrashxor) deleted the joshuac-microsoft-escape-arg-metadata-identifier branch October 13, 2026 22:53
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.

4 participants