I am using byteman 4.0.17. Installing byteman succeeded. Using bmsubmit.sh tool is throwing an error.
$ byteman-download-4.0.17/bin/bmsubmit.sh -y
Failed to process request: java.lang.Exception: Invalid name/value pair in line [HTTP/1.1 400 Bad Request]. Full response below:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close
400 Bad Request
java.lang.Exception: Invalid name/value pair in line [HTTP/1.1 400 Bad Request]. Full response below:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close
400 Bad Request
at [org.jboss.byteman.agent.submit.Submit.listSystemProperties][1](Submit.java:767)
at org.jboss.byteman.agent.submit.Submit.main(Submit.java:1113)
$
Also when I try to submit a rule I get an error.
$ byteman-download-4.0.17/bin/bmsubmit.sh -l /mnt/jenkins/FileDescriptorLeak.btm
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close
400 Bad Request
$
Am I doing something wrong here ?
########################################################################
#
# Rule to trace opening files
#
RULE FileOutputStream open trace
CLASS java.io.FileOutputStream
METHOD <init>
AT EXIT
IF TRUE
DO traceStack("*** Called init in thread " + Thread.currentThread().getName() + "\n", 30)
ENDRULE
The solution to the issue is to define an unused port when using the bminstall command. With the -p flag.
Related
I am trying to use the mailgun Java API for my kotlin project and want to send emails using templates. I believe I have followed the docs but I am getting a 400 Bad Request response.
My kotlin code looks like:
val client = MailgunClient.config("https://api.eu.mailgun.net/", "<raw-api-key>")
.logLevel(Logger.Level.HEADERS)
.createApi<MailgunMessagesApi>(MailgunMessagesApi::class.java)
val message = Message.builder()
.from("Sender name <sender#domain1.com>")
.to("receiver#domain2.com")
.template("template_name")
.subject("Hello")
.mailgunVariables(
mapOf(Pair("param1": "Hello"), Pair("param2": "world"), Pair("param3": "2020-01-01"))
.build()
client.sendMessageFeignResponse(domain, message)
The response logging I get says:
HTTP/1.1 400 Bad Request
access-control-allow-credentials: true
access-control-allow-origin: *
cache-control: no-store
content-length: 78
content-type: application/json;
date: Thu, 22 Dec 2022 00:54:29 GMT
strict-transport-security:
x-xss-protection: 1; mode=block
{}
feign.Response$ByteArrayBody#1744d3cb
I have tried the following and it works in the command line:
curl -s --user 'api:<raw-api-key>' \
https://api.eu.mailgun.net/v3/<user-domain>/messages \
-F from='Sender name <sender#domain1.com>' \
-F to=receiver#domain2.com \
-F template='template_name' \
-F subject='Hello' \
-F t:variables='{"param1": "Hello", "param2": "world", "param3": "2020-01-01"}'
I already implemented the NTLMAuthClient class
rest.client.impl=com.qmetry.qaf.automation.ws.client.NTLMAuthClient
into the project properties but still getting the aforementioned error.
Here is the JSON request template I am using and I am not sure whether the structure is what causes the error:
{
"headers":
{
"Authorization":
[
{
"username": "${ntlm.user}",
"password": "${ntlm.password}"
},
{
"domain": "${ntlm.domain}"
}
],
"Content-Type":"application/json"
},
"endPoint": "",
"baseUrl": "${base_url}/api/data/v4/contacts(integrationkey='${clientNumber}')",
"method": "PATCH",
"body":
{
"userid": ""
}
}
And here's the response from the QMetry report:
Request
Client out-bound request PATCH
https://xxxx.com/CRMDEV2/api/data/v4/contacts(integrationkey='xxxx')
Authorization: [{username=xxxx, password=xxxx},
{domain=xxxx}] Content-Type: application/json
{"userid":""}
Reponse
Client in-bound response 401 REQ_ID:
3d391170-40d7-4ea6-80ca-2531a7fe73ff Server: WWW-Authenticate: NTLM
WWW-Authenticate: Negotiate Set-Cookie:
ReqClientId=21490c2c-bdfe-4c00-9330-401ca0bb5811; expires=Thu,
22-Oct-2071 11:59:11 GMT; path=/; secure; HttpOnly Content-Length: 49
Date: Fri, 22 Oct 2021 11:59:11 GMT Content-Type: text/plain HTTP
Error 401 - Unauthorized: Access is denied
Appreciate the help.
QAF and Selenium version I am using:
QAF version: 2.1.14
Selenium: 3.141.59
Refer NTLMAuthClient java-doc. Instead of Authorization in request call header, you should try providing properties used by NTLMAuthClient.
NTLMAuthClient class uses following properties:
ntlm.user - The user name. This should not include the domain to authenticate with. For example: "user" is correct whereas "DOMAIN\\user" is not.
ntlm.password - The password
ntlm.workstation - workstation (default is blank) The workstation the authentication request is originating from. Essentially, the computer name for this machine.
ntlm.domain- domain The domain to authenticate within (default is blank).
#register NTLMAuthClient
rest.client.impl=com.qmetry.qaf.automation.ws.client.NTLMAuthClient
set above properties in your property file and then try without authorization in request call header.
I'm trying to write an application to manage GCP deployments using the Deployment Manager SDK for Java. I'm able to list deployments successfully but unable to update a deployment as the SDK throws an exception shown below.
com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
"code" : 404,
"errors" : [ {
"domain" : "global",
"message" : "The object 'projects/--redacted-project--/global/deployments' is not found.",
"reason" : "notFound"
} ],
"message" : "The object 'projects/--redacted-project--/global/deployments' is not found."
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:321)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1067)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
My calling code is:
val content = new Deployment().setTarget(target)
val updateResult = client.deployments().update(project, name, content)
.setCreatePolicy("CREATE_OR_ACQUIRE")
.setDeletePolicy("DELETE")
.setPreview(false)
.execute()
When I switch on debug for the SDK I see the following exchange:
2020-04-13 17:52:36,353 [deploy-akka.deploy-dispatcher-10] INFO c.g.a.c.h.HttpTransport - -------------- REQUEST --------------
PUT https://www.googleapis.com/deploymentmanager/v2/projects/--redacted-project--/global/deployments/--redacted-deployment--
Accept-Encoding: gzip
Authorization: <Not Logged>
User-Agent: Google-API-Java-Client Google-HTTP-Java-Client/1.25.0 (gzip)
Content-Type: application/json; charset=UTF-8
Content-Encoding: gzip
Content-Length: 565
2020-04-13 17:52:36,353 [deploy-akka.deploy-dispatcher-10] INFO c.g.a.c.h.HttpTransport - curl -v --compressed -X PUT -H 'Accept-Encoding: gzip' -H 'Authorization: <Not Logged>' -H 'User-Agent: Google-API-Java-Client Google-HTTP-Java-Client/1.25.0 (gzip)' -H 'Content-Type: application/json; charset=UTF-8' -H 'Content-Encoding: gzip' -d '#-' -- 'https://www.googleapis.com/deploymentmanager/v2/projects/--redacted-project--/global/deployments/--redacted-deployment--' << $$$
2020-04-13 17:52:36,354 [deploy-akka.deploy-dispatcher-10] INFO c.g.a.c.h.HttpTransport - Total: 1,449 bytes
2020-04-13 17:52:36,354 [deploy-akka.deploy-dispatcher-10] INFO c.g.a.c.h.HttpTransport - {"target":{"config":{"content":"imports:\n - path: dep.jinja\n\nresources:\n - name: testing\n type: dep.jinja\n properties:\n env: prod\n banana: yes\n retentionInDays: 5"},"imports":[{"content":"resources:\n- name: riffraff-dataset\n type: bigquery.v2.dataset\n properties:\n location: europe-west2\n datasetReference:\n datasetId: riffraff_test\n- name: test-table\n type: bigquery.v2.table\n metadata:\n dependsOn:\n - riffraff-dataset\n properties:\n datasetId: riffraff_test\n tableReference:\n tableId: banana\n schema:\n fields:\n - name: species\n type: string\n - name: plantation\n type: string\n - name: harvested\n type: date\n - name: quantity\n type: numeric\n - name: edible\n type: boolean\n{% if properties['banana'] == \"yes\" %}\n- name: test-topic\n type: gcp-types/pubsub-v1:projects.topics\n properties:\n topic: riffraff-topic\n{% endif %}\n- name: riffraff-bucket\n type: storage.v1.bucket\n properties:\n location: europe-west2\n storageClass: STANDARD\n iamConfiguration:\n uniformBucketLevelAccess:\n enabled: True\n {% if properties['retentionInDays'] %}\n lifecycle:\n rule:\n - action:\n type: Delete\n condition:\n age: {{ properties['retentionInDays'] }}\n {% endif %}","name":"dep.jinja"}]}}
2020-04-13 17:52:37,174 [deploy-akka.deploy-dispatcher-10] INFO c.g.a.c.h.HttpTransport - -------------- RESPONSE --------------
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=UTF-8
Vary: Origin
Vary: X-Origin
Vary: Referer
Content-Encoding: gzip
Date: Mon, 13 Apr 2020 16:52:37 GMT
Server: ESF
Cache-Control: private
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,h3-T050=":443"; ma=2592000
Transfer-Encoding: chunked
So it looks like an invalid URL or object.
However if I use the gcloud CLI tool to do the same thing with --log-http I see that it is hitting exactly the same endpoint but not getting a 404:
==== request start ====
uri: https://www.googleapis.com/deploymentmanager/v2/projects/--redacted-project--/global/deployments/--redacted-deployment--?alt=json&preview=False&createPolicy=CREATE_OR_ACQUIRE&deletePolicy=DELETE
method: PUT
Not sure where to go from here.
After further digging I noticed that the fields in the body JSON in the PUT request were different. The gcloud CLI was sending fingerprint, name and target whilst the Java SDK was only sending target.
Tucked away in the documentation for the request body it says that you need to set fingerprint for update and a handful of other methods.
I modified my code to GET the deployment first and include the fingerprint in the request and it began to work.
val content = new Deployment().setName(name).setFingerprint(fingerprint).setTarget(target)
val updateResult = client.deployments().update(project, name, content)
.setCreatePolicy("CREATE_OR_ACQUIRE")
.setDeletePolicy("DELETE")
.setPreview(false)
.execute()
In my view 404 is the wrong error for this. Google should be returning a 400 as the client is not including a required field in the request.
In addition the SDK does a large number of precondition checks to catch invalid requests but does not include this one. I've opened an issue with Google to suggest this.
I'm trying to send usage data to Microsoft Recommendation API. Here is my request:
POST /recommendations/v4.0/models/ccfb261a-ae96-4ae8-be43-15571fc47a66/usage?usageDisplayName=instasell
Ocp-Apim-Subscription-Key: xxxxxxxx
Content-Length: 409
Content-Type: text/plain; charset=ISO-8859-1
Host: westus.api.cognitive.microsoft.com
Connection: Keep-Alive
User-Agent: InstaSell.ru
Accept-Encoding: gzip,deflate
"19vu1oowsiupsrnnln7eu82ln,8,2016/06/15T01:16:30,AddShopCart[\n]"
"19vu1oowsiupsrnnln7eu82ln,8,2016/06/15T01:16:30,AddShopCart[\n]"
"77,8,2016/06/15T01:16:30,AddShopCart[\n]"
"77,9,2016/06/15T01:16:30,AddShopCart[\n]"
"77,134,2016/06/15T01:16:30,Click[\n]"
"77,134,2016/06/15T01:16:30,AddShopCart[\n]"
"77,134,2016/06/15T01:16:30,AddShopCart[\n]"
"77,8,2016/06/15T01:16:30,AddShopCart[\n]"
"77,8,2016/06/15T01:16:30,AddShopCart[\n]"
"77,8,2016/06/15T01:16:30,Click"
But receive the following response:
{
"fileId":"c224766e-1e2a-405e-9367-37a0d36973d0",
"processedLineCount":10,
"errorLineCount":1,
"importedLineCount":9,
"errorSummary":[
]
}
I don't see any differences in 10 lines. However microsoft api comlaints. Could you please help?
Ah! I finally understood the issue. It looks like I was trying to import usage about items unknown to API.
When I imported catalog, I filtered some of the invalid products/items. But usage data included them.
It's normal to reject invalid usage data during production. I was testing integration, so it should be perfectly clear why some usage points were rejected
I am downloading a file with okhttp and things work fine - now I want to show the progress and hit a road-bump. The returned content-length is -1.
It comes back correctly from the server:
⋊> ~ curl -i http://ipfs.io/ipfs/QmRMHb4Vhv8LtYqw8RkDgkdZYxJHfrfFeQaHbNUqJYmdF2 13:38:11
HTTP/1.1 200 OK
Date: Tue, 14 Jun 2016 11:38:16 GMT
Content-Type: application/octet-stream
Content-Length: 27865948
I traced the problem down to OkHeaders.java here:
public static long contentLength(Headers headers) {
return stringToLong(headers.get("Content-Length"));
}
I see all the other headers here in headers - but not Content-Length - so headers.get("Content-Length") returns null. Anyone has a clue how this can get lost?
Interestingly if I change the url to "http://google.com" I get a content-length from okhttp - but with curl both look same Content-Length wise - this really confuses me
Update: it seems to correlate with he size of the file. If I use smaller content from the same server I get a Content-Length with okhttp. The problem only happens when the file is big
It looks like above a certain size the server uses chunked encoding and you won't get a content length.
HTTP/1.1 200 OK
Date: Tue, 14 Jun 2016 14:30:07 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked