Teradata / PyTd

A Python Module to make it easy to script powerful interactions with Teradata Database in a DevOps friendly way.
MIT License
108 stars 43 forks source link

ValueError: Invalid placeholder in string: ==> Special character "$" in password #47

Closed asifhj closed 8 years ago

asifhj commented 8 years ago

If password of teradata server contains special character "$" then following exception will be thrown and execution is termination

return udaExec.connect(method=method, system=system, username=username, password=password)

File "C:\Python27\lib\site-packages\teradata\udaexec.py", line 149, in connect args.update(self.config.resolveDict(kwargs)) File "C:\Python27\lib\site-packages\teradata\udaexec.py", line 563, in resolveDict d[key] = self._resolve(value, sections, None, None) File "C:\Python27\lib\site-packages\teradata\udaexec.py", line 584, in _resolve value.replace("$$", "$$$$")).substitute(**s) File "C:\Python27\lib\string.py", line 176, in substitute return self.pattern.sub(convert, self.template) File "C:\Python27\lib\string.py", line 173, in convert self._invalid(mo) File "C:\Python27\lib\string.py", line 146, in _invalid (lineno, colno)) ValueError: Invalid placeholder in string: line 1, col 12 2016-07-12 16:34:49,221.221.999883652:teradata.udaexec:4840:INFO:9928:UdaExec exiting.

escheie commented 8 years ago

I've confirmed that escaping the $ with another $ does solve the issue.

It looks like if the dollar sign is anywhere but the last character of the password, than a more useful error message is returned.

teradata.api.InterfaceError: ('CONFIG_ERROR', 'Unable to resolve variable "pas$word". Not found: \'word\'')

But I do see the stack trace above when the $ is at the end of the password.

I'll work on a fix that will improve the error message and include instructions about how to escape the input if a parameter reference is unintended. Thanks for reporting.

escheie commented 8 years ago

Closing this pull request as it resolves the issue by disabling external parameter references for all but the username key.