Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute name with colon can't be transform in XML file type #34

Closed
iKaew opened this issue Nov 14, 2017 · 5 comments
Closed

Attribute name with colon can't be transform in XML file type #34

iKaew opened this issue Nov 14, 2017 · 5 comments
Assignees
Labels
Milestone

Comments

@iKaew
Copy link
Contributor

iKaew commented Nov 14, 2017

When do transform with applicationsettings with the attribute key that contain colon, it will error.

Version: 1.2.0

Sample config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="blog:theme" value="green" />
  </appSettings>
</configuration>

Sample transform config

{
  "configuration/appSettings/add[@key='blog:theme']/@value": "red",
}

Error :

2017-11-14T11:04:04.9849036Z ##[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "The ''' character, hexadecimal value 0x27, cannot be included in a name." ---> System.Xml.XmlException: The ''' character, hexadecimal value 0x27, cannot be included in a name.
2017-11-14T11:04:04.9849036Z    at System.Xml.XmlConvert.VerifyNCName(String name, ExceptionType exceptionType)
2017-11-14T11:04:04.9849036Z    at System.Xml.Linq.XName..ctor(XNamespace ns, String localName)
2017-11-14T11:04:04.9849036Z    at System.Xml.Linq.XNamespace.GetName(String localName, Int32 index, Int32 count)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Helpers.XmlExtensions.GetNameWithNamespace(String name, XElement element, String defaultNamespace)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Helpers.XmlExtensions.<>c__DisplayClass1_0.<GetChildElementByName>b__0(XElement e)
2017-11-14T11:04:04.9982685Z    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Documents.XmlDocument.FindPath(IEnumerable`1 path, XElement current, String documentNamespace)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Documents.XmlDocument.ReplaceKey(String[] path, String value)
2017-11-14T11:04:04.9982685Z    at MagicChunks.Core.Transformer.Transform(IDocument source, TransformationCollection transformations)
2017-11-14T11:04:04.9982685Z    at MagicChunks.TransformTask.Transform(String type, String sourcePath, String targetPath, TransformationCollection transformation)
2017-11-14T11:04:04.9982685Z    at CallSite.Target(Closure , CallSite , Type , Object , Object , Object , Object )
2017-11-14T11:04:04.9982685Z    --- End of inner exception stack trace ---
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2017-11-14T11:04:04.9982685Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
@sergeyzwezdin sergeyzwezdin self-assigned this Nov 15, 2017
@sergeyzwezdin sergeyzwezdin added this to the 1.3.0 milestone Nov 15, 2017
@wasabii
Copy link

wasabii commented Nov 16, 2017

I also noticed this. It actually works fine with two colons! There's something trying to parse it as a XML prefix I bet.

@sergeyzwezdin
Copy link
Member

Fixed by @iKaew. Thank you!

@sergeyzwezdin
Copy link
Member

Latest fixes were released to Nuget and VS Marketplace.

@iKaew
Copy link
Contributor Author

iKaew commented Dec 25, 2017

Hi @sergeyzwezdin,

I try the latest version of 1.* on my VSTS. I seem like the issue still there.
I got the extension version 1.3.10 not sure it's exactly the same with 1.3.1 that the code merged into.

Log below


2017-12-25T03:50:43.0648379Z ##[section]Starting: Config transform - Recognition.Engine.Agent.Post.exe.config
2017-12-25T03:50:43.0658382Z ==============================================================================
2017-12-25T03:50:43.0658382Z Task         : Config transformation
2017-12-25T03:50:43.0658382Z Description  : Transform config file with Magic Chunks
2017-12-25T03:50:43.0658382Z Version      : 1.3.10
2017-12-25T03:50:43.0658382Z Author       : Sergey Zwezdin
2017-12-25T03:50:43.0658382Z Help         : [More Information](https://github.com/sergeyzwezdin/magic-chunks)
2017-12-25T03:50:43.0658382Z ==============================================================================
2017-12-25T03:50:43.0888373Z Preparing task execution handler.
2017-12-25T03:50:43.6268231Z Executing the powershell script: C:\vstsagent\A2\_work\_tasks\MagicChunks_985284e0-a7d2-4e4d-802c-0a516bffaadf\1.3.10\transform.ps1
2017-12-25T03:50:43.6268231Z   "configuration/appSettings/add[@key='A:A']/@value": "{Removed}", 
2017-12-25T03:50:43.6268231Z   "configuration/appSettings/add[@key='A:B']/@value": "{Removed}"
2017-12-25T03:50:43.6278235Z })


2017-12-25T03:50:46.0252594Z ##[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "The ''' character, hexadecimal value 0x27, cannot be included in a name." ---> System.Xml.XmlException: The ''' character, hexadecimal value 0x27, cannot be included in a name.
2017-12-25T03:50:46.0272591Z    at System.Xml.XmlConvert.VerifyNCName(String name, ExceptionType exceptionType)
2017-12-25T03:50:46.0282585Z    at System.Xml.Linq.XName..ctor(XNamespace ns, String localName)
2017-12-25T03:50:46.0332568Z    at System.Xml.Linq.XNamespace.GetName(String localName, Int32 index, Int32 count)
2017-12-25T03:50:46.0362564Z    at MagicChunks.Helpers.XmlExtensions.GetNameWithNamespace(String name, XElement element, String defaultNamespace)
2017-12-25T03:50:46.0362564Z    at MagicChunks.Helpers.XmlExtensions.<>c__DisplayClass1_0.<GetChildElementByName>b__0(XElement e)
2017-12-25T03:50:46.0362564Z    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
2017-12-25T03:50:46.0362564Z    at MagicChunks.Documents.XmlDocument.FindPath(IEnumerable`1 path, XElement current, String documentNamespace)
2017-12-25T03:50:46.0362564Z    at MagicChunks.Documents.XmlDocument.ReplaceKey(String[] path, String value)
2017-12-25T03:50:46.0362564Z    at MagicChunks.Core.Transformer.Transform(IDocument source, TransformationCollection transformations)
2017-12-25T03:50:46.0372579Z    at MagicChunks.TransformTask.Transform(String type, String sourcePath, String targetPath, TransformationCollection transformation)
2017-12-25T03:50:46.0372579Z    at CallSite.Target(Closure , CallSite , Type , Object , Object , Object , Object )
2017-12-25T03:50:46.0372579Z    --- End of inner exception stack trace ---
2017-12-25T03:50:46.0372579Z    at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2017-12-25T03:50:46.0372579Z    at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2017-12-25T03:50:46.0372579Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2017-12-25T03:50:46.0372579Z    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2017-12-25T03:50:46.0372579Z ##[error]PowerShell script completed with 1 errors.

Thanks

@sergeyzwezdin
Copy link
Member

@iKaew I had to rollback this updated because of #42 - once it will be resolved new version will be available under 2.x.
Use #42 to watch the status of issue and this update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants