google-cloud-build PyPi 400 errors - google-cloud-platform

I am currently receiving 400 errors when invoking the list_builds() method (seen here: https://googleapis.dev/python/cloudbuild/latest/gapic/v1/api.html?highlight=list_builds#google.cloud.devtools.cloudbuild_v1.CloudBuildClient.list_builds)
The following command works using gcloud:
gcloud builds list --filter="status=FAILURE"
However, the following API call returns google.api_core.exceptions.InvalidArgument: 400 Error processing filter expression
for element in client.list_builds("REDACTED", filter_="status=FAILURE"):
# process element
pass
I'm guessing I'm missing something very obvious and simple here but I can't exactly figure out what I'm doing wrong

The correct way to pass in the filter string to the API call includes using double apostrophes around the actual text like so:
filter_='status="FAILURE"'
Unsure of whether or not this will be changed in the future, but this is the same behavior for passing it in via the REST API here: https://cloud.google.com/cloud-build/docs/api/reference/rest/v1/projects.builds/list
e.g specifiying status=FAILURE will fail, but status="FAILURE" returns a 200 response.

welcome to Stack O! So I'm just spitballing here, but the docs say that the Filter string is "The raw filter text to constrain the results."
When you filter a Cloud Build in the console, the "raw filter text" in the UI says Status : Failed - you could try:
--filter="Status : Failed"
--filter="Status: Failed"
--filter="Status:Failed"
Alternately, it might be the string in the URL, the formatting of which is too bananapants for Stack O's robots to handle, so I can't paste it here, but it starts with f and ends with Failed:
The key here is that you have an equal sign in your string, as well as Failure instead of Failed - changing one or both of those might do the trick.
Hope this helps!

Related

"An error was encountered with the requested page" in jmeter even capture variables by using regular expression extractor

I have used jmeter to record login flow of application , when i re run it there are some requests failing so i fetch dynamic values from earlier responses and supplies those values to subsequent requests
I am facing some issues there is State token in requests but format of this is changing dynamically so because of that when i rerun some time requests are passing some time failing
Here those are
Fail case
{"stateToken":"00UaBoY\x2D81AIL32Nz9qmUJrIarSv3OgfUdd8FHGSkb"}
{"stateToken":"00C8O4pt\x2DcSPEzHrt69zqmEGta9KbjdwywEVdkICku"}
{"stateToken":"00JgMsy7\x2DzXDP0gxaeWv4dj8EguFTWtnLxV\x2DBKTkIq"}
Working case
{"stateToken":"00fswJVHKpW7dNhNVK0bRclBBrsuMLHBBevJ8IS1Wz"}
{"stateToken":"00ZVZXpSJn7v3lxNTrEqy1mAGydgroO5apvoTlWH2u"}
My regular expression for capture state token is stateToken":"(.+?)"
what is issue here ?
the second issue is saml,relay state are not working even regax working fine in regax tester , i am getting "An error was encountered with the requested page". in debug sampler those 2 variables are getting and passed ( screenshot is attached )
Anyone have ideas related above 2 issues please give some ideas to sort out this
Your failing requeststokens have\x`.
You will have to encode the value and send the request.
In HTTP Request
Check the filed URL encode?
Encoding the value with function
It sounds like a bug in your application, I don't think it's JMeter issue, presumably it's due to presence of these \x2D characters (may be incorrect work of unicode escape)
I don't know what does your application expect instead of this \x2D try to inspect the JavaScript code of the application to see what it does do the tokens, when you figure this out you can replicate this token conversion logic in JSR223 PreProcessor and Groovy language

Jmeter : One request - two or more responses - how to Regular Expression Extractor?

Hello.
I met the following problem.
What I should do:
I need to make a performance test of services. I don't have documentation. In this case, I record the requested services and responses using Jmeter and the browser. Then I review every one sample and add a regular expression extractor - if it's needed.
What's the problem?
The problem that I met is when I run the script from Jmeter, some requests have two or more responses. When I use regular expression extractor or response assertion, I noticed that the extractor or assertion is applied only to the last response. So can I apply the regular expression extractor and response assertion to responses that I need?
Here are some screenshots for more details:
This picture shows that we have two responses from one request and you can see details about the first response.
This picture shows details about the second response.
This picture shows the response code for the first response.
Same as the previous picture, but I added a Response Assertion - to check if the assertion works for the first response.
This picture shows the response code for the second response.
This picture shows the assertion failure.
Why has this has happened?
Probably this happened because I hit an URL (endpoint), and this URL forces other requests, that weren't recorded. So... maybe I need to configure the recorder options in another way.
Whats the questions:
Is there is a way to choose what response I can use with a regular expression extractor? For example, there are two responses and I want to use a regular expression extractor to the first one.
Which are the best settings for recording using Jmeter?
"Whats the answers":
No, you have choice between Main sample and sub-samples, main sample only, sub-samples only or JMeter Variable
The ones which are defined in the Recording Template are most probably the best, at least they're better than anything else I've seen so far. The general approach of "recording" might be a big mistake itself, at least for Web 2.0, I believe there are way better options of replicating browser traffic.
Coming back to your first question and possible solutions: you're basically being redirected that's why you're getting 2 subresults, one with status code 302 and another one with 200
With normal Response Assertion you can only amend its configuration to take both status codes as successful:
If you want to test that exactly the first subresult has status code of 302 - you will have to go for JSR223 Assertion and implement the acceptance criteria in Groovy.
Example code:
if (prev.getSubResults().first().getResponseCode() != '302') {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('Response code mismatch, expected: 302, got: ' + prev.getSubResults().first().getResponseCode())
}

Viewstate Replacing error. [ViewStateException: Invalid viewstate. ]

Tried with JMeter: How to know why my regular expression extractor in JMeter is not extracting the data but still not able to replace my view-state, its throwing [ViewStateException: Invalid viewstate. ] error . Please check the attachment , an my script has not _EVENTVALIDATION .
enter image description hereViewstate
viwstate2
As i am observing from your attached image
You need to pass same `Reference name` as a value of __VIEWSTATE in Next request
First Cross verify, Is your correaltion is correct or not? (you can use debug sampler to check the correlation)
If yes, then first mistake is, you had given reference name as "VIEWSTATE" in below shown snapshot
But you are passing ${jsfViewState} in other snapshot, so correct it and pass same reference name i.e. ${VIEWSTATE}
It'll resolve your issue, if issue still persists then click on encode button beside Name-Value pair because sometimes there is some mismatch in encoding format between the response which we capture and the value which we have to pass
Don't be confused with ASP.NET ViewState and JSF Viewstate, they have similar nature but different underlying technologies and different parameter names
Given you correctly correlated the value, I believe you need to change __VIEWSTATE parameter name to javax.faces.ViewState and it should work.
See Testing a JSF Application with JMeter guide for a little bit more detailed explanation on the topic and How to debug your Apache JMeter script guide for some troubleshooting techniques.

How to in JMeter use regular expression extractor to fill request in loop

I've got simple test plan:
Jdbs Conection
JDBC request
For Each Loop on jdbc response
|-Regular Expression Extractor (Post processor)
|-Soap Request where I need extracted value from Regular Expression Extractor
|-Response assertion
The problem is when the first loop is executed. SOAP request is filled with name of variable from Regular Expression Extractor not the value. Can anyone tell me how to get around this problem?
[Edit] test plan screen
As you can see on the first image is showing jdbc response data . On first position is value '22;1'. Second one is showing first soap request failed not a values but names of variables... Third one is showing second request filled correctly
http://postimg.org/image/owl5kue4v/
Below is screen when I add Debug Sampler to for each loop. In this situation first SOAP request is filled correctly.
http://postimg.org/image/aad3c0ngt/
My problem is how to get the same behavior like in second situation but without adding Debug Sampler?
BTW, Sorry for the images on an external server, but my rank is too low to add them here
Your test plan should be in the format mentioned in the attached snapshot:
Hope this will help

Issues with raw_post_data decoding in Django

I have stumbled on a strange issue that I can't resolve:
In my Django app there is a method which gets hit by a POST from a java applet, which sends it a JSON object. Django method parses it like so:
req = json.loads(request.raw_post_data)
and based on the results returns a value. I haven't written this code, but yesterday I was sent to investigate an error triggered in this method. It was saying there was "ValueError: Expecting property name: line 1 column 1 (char 1)".
What I discovered is that my raw post data looks like this:
{#012#011"ImmutableMachineFactors": #012#011{#012#011#011"machineName": "lukka",#012#011#011"osName": "MacOS"}}
The type of it was string, however, my attempts to replace these weird characters with spaces or nothing failed. It would just ignore the sub() command. I know that raw_post_data returns a bytestring, but when I tried to convert it to a regular string using:
mystring.decode('utf-8')
it did add the u'' notation, but didn't remove those weird characters. Stranger still, in many cases (on my personal machine), Django would happily convert this kind of data into JSON, it only fails sometimes, which led me to believe that the JSON which triggered the error was malformed, but when I would strip out all the #011 and #012 characters, it parsed perfectly.
My questions are:
1) What are those crazy things? (#011, #012). I tried to google around, but these are very common things to find in a search, so I couldn't find anything relevant.
2) How can I turn this bytestring into a regular string so that I can replace those characters? Or is it the wring way to approach this problem?
Thanks!
Luka
This may be way too late to help, but since QueryDict instances (request.POST or request.DATA) are immutable, it's reasonable to expect that request.raw_post_data is also immutable. You'd have to make a copy before changing it.