How to maintain the escaped quotes in an expression in Spring Cloud Data Flow? - spring-cloud-dataflow

When I configure my stream to be depoyed, in which I'm using a processor (transform, script or http-request), in the "expression" atribute I need to set an expression that contains quotes and double quotes (escaped). The expression works properly the first time I set and allows to deploy the stream, but if I undeploy the stream and try again to deploy it, the spring cloud data flow throws state machine exception because the backslashes used to escape the double quotes are removed.
I already follow the considerations in the Spaces and Quotes documentation, but I think that it only applies to the streams definition and not to the deployment time.
The URL of the spaces and quotes documentarion is: https://docs.spring.io/spring-cloud-dataflow/docs/current-SNAPSHOT/reference/htmlsingle/#shell-white-space
And the sample of the type of expression required:
expression="new String('{\"size\": 1,\"sort\": {\"timestamp\": \"desc\"},\"query\": {\"prefix\": {\"integrationname\": \"63320e0d313862934667225f\"}}}')"
The stream could be as simple as:
http | transform | log
The firs time the expression is set looks like as follows:
expression="new String('{\"size\": 1,\"sort\": {\"timestamp\": \"desc\"},\"query\": {\"prefix\": {\"integrationname\": \"63320e0d313862934667225f\"}}}')"
Deploying correctly the stream.
Once the stream is undeployed and try to deploy it again, the espression looks like:
expression="new String('{"size": 1,"sort\": {"timestamp": "desc"},"query": {"prefix": {"integrationname": "63320e0d313862934667225f"}}}')"
Where the backslashes were removed, causing the state machine exception because of the unescaped double quotes.
Thanks in advance

We are looking at Issue #5145 and will update the issue when we have fixed it.
In the meantime I would suggest using the spring-cloud-dataflow-shell or the REST API to automate deployments where you provide the properties every time as needed.

Related

VS Code Jenkinsfile docker.withRegistry {...} brackets do not match error

I'm writing a jenkinsfile in VS Code and when I use docker.withRegistry("some.registry"){...} I get a brackets do not match error inside of code. It parses fine inside jenkins, but this error inside of code is bugging me a lot. As soon as anything goes between the {} I get the error show up on the closing bracket.
Even copying in directly from the documentation from the Jenkins website gives the same issue.
Any ideas?
Oddly enough I had the same issue when I was using a private registry with a credentials ID, when I switched away from single quotes to double quotes the error went away, you could give that a try?
docker.withRegistry("https://some.registry", "docker-registry-creds") {
def customImage = docker.build("my-image:${env.GIT_COMMIT}")
}
As mentioned by Carl here, this happens when you have the following 2 characters, in this particular order, in a single quoted string:
'/*'
So strings like the following will trigger the error:
'**/*.xml'
'/some/path/to/random/files/*.py'
Just use double quote in those strings, and all the errors will go away:
"**/*.xml"
"/some/path/to/random/files/*.py"
I noticed this also occurs when using a parenthesis in single quotes. Again fixed by putting these in double quotes.
e.g.:
def something= somethingelse.tokenize('(')
can be replaced by
def something= somethingelse.tokenize("(")

invalid URL escape "%" when docker push

I set up a registry at docker-registry.elektron.space and when I want to push an image with $ docker push docker-registry.elektron.space/boxbeat-media-server, the upload animation is running in loop for each entity passing from "Pushing" state to "Retrying in X seconds".
After a while I get this error:
failed to parse Location header "https://docker-registry.elektron.space/v2/boxbeat-media-server/blobs/uploads/56244149-c196-439a-85bf-af1121e0b84b%?_state=h1lqY-NljkLbgzTCjd8jxcfdscojPHApblWu-45ISK57Ik5hbWUiOiJib3hiZWF0LW1lZGlhLXNlcnZlciIsIlVVSUQiOiI1NjI0NDE0OS1jMTk2LTQzOWEtODViZi1hZjExMjFlMGI4NGIiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjAtMDMtMDFUMTU6MzI6NTAuMzcxNjc5NTc5WiJ9": parse https://docker-registry.elektron.space/v2/boxbeat-media-server/blobs/uploads/56244149-c196-439a-85bf-af1121e0b84b%?_state=h1lqY-NljkLbgzTCjd8jxcfdscojPHApblWu-45ISK57Ik5hbWUiOiJib3hiZWF0LW1lZGlhLXNlcnZlciIsIlVVSUQiOiI1NjI0NDE0OS1jMTk2LTQzOWEtODViZi1hZjExMjFlMGI4NGIiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjAtMDMtMDFUMTU6MzI6NTAuMzcxNjc5NTc5WiJ9: invalid URL escape "%"
In a readable way:
failed to parse Location header
"https://docker-registry.elektron.space/v2/boxbeat-media-server/blobs/uploads/
56244149-c196-439a-85bf-af1121e0b84b%?_state=
h1lqY-NljkLbgzTCjd8jxcfdscojPHApblWu-45ISK57Ik5hbWUiOiJib3hiZWF0LW1lZGlhLXNlcnZlciIsIlVVSUQiOiI1NjI0NDE0OS1jMTk2LTQzOWEtODViZi1hZjExMjFlMGI4NGIiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjAtMDMtMDFUMTU6MzI6NTAuMzcxNjc5NTc5WiJ9":
parse https://docker-registry.elektron.space/v2/boxbeat-media-server/blobs/uploads/
56244149-c196-439a-85bf-af1121e0b84b%?_state=
h1lqY-NljkLbgzTCjd8jxcfdscojPHApblWu-45ISK57Ik5hbWUiOiJib3hiZWF0LW1lZGlhLXNlcnZlciIsIlVVSUQiOiI1NjI0NDE0OS1jMTk2LTQzOWEtODViZi1hZjExMjFlMGI4NGIiLCJPZmZzZXQiOjAsIlN0YXJ0ZWRBdCI6IjIwMjAtMDMtMDFUMTU6MzI6NTAuMzcxNjc5NTc5WiJ9:
invalid URL escape "%"
Where does this "%" come from? I thought this could come from zsh then I tried to run it with bash but same result.
Any idea?
The issue is that a % sign is used to initiate an escape sequence in url encoding. You need to escape the % itself.
So in your case you should replace the % with %25 which is the escaped form if it. That way you don't get the error because the parser doesn't think an escape sequence is about to start when it sees the %
... /uploads/56244149-c196-439a-85bf-af1121e0b84b%25 ...
This article can also help to understand things better. Even though its about javascript, the information is applicable much broader.
You can lookup escape sequences on this page.

SIebel Data Mapping issue

We have a web service that integrated our siebel system which another system.
Any update in the account would trigger the web service. But webservice trigger is not happening due to the following error:
Error invoking service 'EAI Data Transformation Engine', method 'Execute' at step 'Generate Org Msg'.(SBL-BPR-00162)
--
Error parsing expression 'Name='Master's College & University', Type='LN_INDUSTR
I believe it is because of the apostrophe in the Name = 'Master's College & University'.
There is this mapping which is responsible for mapping our value to the external service:
Source Expression: IfNull([&IndustryClass],[LN Industry Class])
I tried using the InStr function to see if that solves the issue, but to no avail
InStr([LN Industry Class],[LN Industry Class])
Do we have a workaround for this issue?
You have to replace the single quote (apostrophe: ') with a double quote (") and wrap the text with single quotes.
More info here.

Objective-C Remove ANSI Color Control Codes

I'm building an iOS application that communicates with a remote server. In this case, I'm executing commands using SSH, however, the response coming back from the server is coming in the form of what appears to be hexadecimal. My delegate function for handling responses from a remote server takes the response argument as an NSString, however, this is the content of the string returned (command executed was "ls /" )
ls /\r\n\x1b[0m\x1b[01;34mbin\x1b[0m \x1b[01;34mdev\x1b[0m \x1b[01;36minitrd.img\x1b[0m \x1b[01;34mlib64\x1b[0m \x1b[01;34mmnt\x1b[0m \x1b[01;34mroot\x1b[0m \x1b[01;34msrv\x1b[0m \x1b[01;34musr\x1b[0m\r\n\x1b[01;34mboot\x1b[0m \x1b[01;34metc\x1b[0m \x1b[01;36minitrd.img.old\x1b[0m \x1b[01;34mlost+found\x1b[0m \x1b[01;34mopt\x1b[0m \x1b[01;34mrun\x1b[0m \x1b[01;34msys\x1b[0m \x1b[01;34mvar\x1b[0m\r\n\x1b[01;34mcdrom\x1b[0m \x1b[01;34mhome\x1b[0m \x1b[01;34mlib\x1b[0m \x1b[01;34mmedia\x1b[0m \x1b[01;34mproc\x1b[0m \x1b[01;34msbin\x1b[0m \x1b[30;42mtmp\x1b[0m \x1b[01;36mvmlinuz\x1b[0m'
If this is in fact hexadecimal, how to I convert this back to a readable string for display purposes? If it's not hexadecimal, does anyone know what it is?
EDIT:
Since this is ANSI Color Control Codes, what's the best method to remove them?
prepend "\" to the beginning of the command
$ \ls
or provide handling for the escape sequences (strip, display)

URLTrigger plugin. Need examples for TXT-RegEx or XML-XPath

So, I try to use plugin https://wiki.jenkins-ci.org/display/JENKINS/URLTrigger+Plugin.
I want to trigger my Jenkins job when the text "Last build (#40), 17 hr ago" in the response of provided URL is changed (build number will be different after each build).
So I made following configurations:
1. Build trigger: Set [URLTrigger] - Poll with a URL.
2. Specified URL to another Jenkins: http://mydomain:8080/job/MasterJobDoNothing/
3. Set Inspect URL content option
4. Set Monitor the contents of a TEXT response
5. Set following regular expression: ^Last build[.]*
6. Set Schedule every minute: * * * * *
7. Trigger the job on another Jenkins
Actual result: My job wasn't triggered.
Then I tried to deal with XML/XPath and specify
8. Set Monitor the contents of an XML response
9. Set XPath: //*[#id="side-panel"] (also tried with one "/")
Actual result: the same.
Tell me please what I'm doing wrong? Please provide examples of RegEx or XPath if possible.
Thanks, Dima
I managed to trigger reliably with regex setting.
The regex pattern matches each line of the input.
No need to use ^ or $. it always match line start to line end.
This plugin compares the contents of the matched lines. It triggers if different.
This plugin compares the count of the matched lines. It triggers if the count is different.
This plugin uses matches() method of java.util.regex.Matcher. So the regex pattern should conform to it. (it's fairly normal regex)
As for your example,
Last build.*
may work.
Refs:
Reference of regex patten:
http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
Reference of Matcher: http://docs.oracle.com/javase/7/docs/api/java/util/regex/Matcher.html#matches()
The regex trigger source code:
github.com/jenkinsci/urltrigger-plugin/blame/master/src/main/java/org/jenkinsci/plugins/urltrigger/content/TEXTContentType.java
I'd recommend to use the "RSS for all" link as a trigger URL instead, and /feed/entry[1] as the XPath expression for the XML response content nature.
PS: I was using PathEnq to debug the XPath expression.

Resources