Hello everyone,
I recently encountered an unexpected issue when saving a custom Python script in an ArcGIS Pro toolbox (.atbx). Parts of a formatted string within the code are removed or replaced with spaces upon saving. Specifically, the affected string is: xmlns="urn:Redlines.xsd"
The issue occurs regardless of whether the value is stored in a normal string, a formatted string, or a multiline string.
Issue Details:
After saving the tool inside the toolbox, the string xmlns="urn:Redlines.xsd" is either removed or replaced with spaces. This happens when:
The Python tool is opened in the code editor and saved using the "OK" button.
The problem is reproducible across different toolbox versions, different ArcGIS Pro projects, different users, and different ArcGIS Pro versions (3.3.0 and 3.3.2). However, this issue does not occur within Python toolboxes (.pyt).
Tested Environment:
ArcGIS Pro 3.3.2 (also occurs in 3.3.0)
Multiple different toolbox files (.atbx) tested
The issue is independent of the toolbox version
Expected Behavior:
The original string should remain unchanged and should not be automatically modified upon saving.
Questions:
Is this a known issue?
Is there a way to prevent the automatic removal or replacement of the string?
If this is a bug, is there a known fix or workaround?
My Workaround:
To avoid this issue, I encoded the string in Base64 and then decoded it at runtime:
import base64
# Base64 encoded string to preserve the value
encoded_str = "eG1sbnM9InVybjpSZWRsaW5lcy54c2Qi"
# Decode Base64 back to the original string
decoded_bytes = base64.b64decode(encoded_str)
decoded_str = decoded_bytes.decode('utf-8')
This ensures that the string remains intact when saved in the toolbox.
Has anyone else encountered this issue? If so, do you know why this happens, and are there alternative solutions?
Thanks in advance for any insights!
Best Regards
Daniel