getting the following error while trying to follow sample code to generate surrogate hash by setting cryptoHashConfig
{ Error: In KmsWrappedCryptoKey
at Http2CallStream.call.on (/home/stoyak/Aritzia/dlp_api/node_modules/#google-cloud/dlp/node_modules/#grpc/grpc-js/build/src/client.js:103:45)
at Http2CallStream.emit (events.js:187:15)
at Http2CallStream.endCall (/home/stoyak/Aritzia/dlp_api/node_modules/#google-cloud/dlp/node_modules/#grpc/grpc-js/build/src/call-stream.js:74:18)
at handlingTrailers (/home/stoyak/Aritzia/dlp_api/node_modules/#google-cloud/dlp/node_modules/#grpc/grpc-js/build/src/call-stream.js:163:18)
at process._tickCallback (internal/process/next_tick.js:68:7)
code: 3,
details: 'In KmsWrappedCryptoKey',
metadata: Metadata { internalRepr: Map {} },
note:
'Exception occurred in retry method that was not classified as transient' }
And here is the request that was used
{
"parent":"projects/XXXX",
"item":{
"value":"XXXXXXXX"
},
"deidentifyConfig":{
"infoTypeTransformations":{
"transformations":[
{
"primitiveTransformation":{
"cryptoHashConfig":{
"cryptoKey":{
"kmsWrapped":{
"wrappedKey":"CiQAnHQoiec0s1myvgJiQf+NjFKQ1MxzN2s+v/Jq74ek3tqhnRoSMAAEfzpfTLYI6jaMSRN4J8Q6wOZ0glgNF9UR9N+HxY+dhyTiggHwVQRnbrNnKU9MUw==",
"cryptoKeyName":"projects/XXXX/locations/global/keyRings/XXX/cryptoKeys/XXX"
}
},
"commonAlphabet":"ALPHA_NUMERIC"
}
}
}
]
}
}
}
Code 3 is an invalid input exception. My guess if if you inspect the http response you'll get a better tip as to what is wrong.
What you are looking for is the error response that looks like this
{
"error": {
"code": 400,
"message": "The item has a mistake......",
"status": "INVALID_ARGUMENT",
}
}
To rule out error handling in the client library, do you mind trying the same call via the Api Explorer? https://developers.google.com/apis-explorer/#p/dlp/v2/dlp.projects.content.deidentify
Related
Following the docs I've set up this handler inside routes():
this.put(
'/admin/features/error/environment/test',
// #ts-ignore
() => new Response(500, {}, { errors: ['The database went on vacation'] }),
);
Mirage does receive what I've set, sort of. Here is its response, from the browser console logs. Note that it's not an error although the 500 shows up in _bodyInit:
{
"type": "default",
"status": 200,
"ok": true,
"statusText": "",
"headers": {
"map": {
"content-type": "text/plain;charset=UTF-8"
}
},
"url": "",
"bodyUsed": false,
"_bodyInit": 500,
"_bodyText": "[object Number]"
}
Note that I need ts-ignore which is probably a clue. TS complains that new Response expects 0-2 arguments but got 3.
Try importing the Mirage Response class:
import { Response } from 'miragejs';
Otherwise, Response refers to a Fetch API Response object. This explains the type checking error and the unexpected behavior when calling the route.
After adding the import you can remove #ts-ignore and requests to the route should fail with status code 500.
I am trying to create a new group and team via the Graph API. I am trying to run the POST a request in Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) as below but get a bad request.
Request: POST
Version: v1.0
URL: https://graph.microsoft.com/v1.0/teams/groups
Request Body:
{
"displayName":"Flight 157",
"mailNickname":"flight157",
"description":"Everything about flight 157",
"visibility":"Private",
"groupTypes":["Unified"],
"mailEnabled":true,
"securityEnabled":false,
"members#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
],
"owners#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
]
}
I get the below response error:
{
"error": {
"code": "BadRequest",
"message": "Invalid bind property name members in request.",
"innerError": {
"request-id": "fee10382-5112-44f8-a8c9-683453bdf050",
"date": "2020-03-05T01:08:19"
}
}
}
I am not quite sure what I am doing wrong. Can anyone please help me with this?
I am sending an HTTP PUT request to my Elasticsearch server using Fuel library on Kotlin. However, I cannot see an error body if the server returns 404 or 400. I am expecting to get an error message similar to the following:
{
"error": {
"root_cause": [
{
"type": "invalid_snapshot_name_exception",
"reason": "[snap1:kopya3]Invalid snapshot name [kopya3], snapshot with the same name already exists"
}
],
"type": "invalid_snapshot_name_exception",
"reason": "[snap1:kopya3]Invalid snapshot name [kopya3], snapshot with the same name already exists"
},
"status": 400
}
Here's my code:
val (request, response, result) = fullUrl
.httpPut()
.body(payload)
.responseString()
val (bytes, error) = result
print(error)
Instead what I see is:
HTTP Exception 400 Bad Request
com.github.kittinunf.fuel.core.FuelError$Companion.wrap(FuelError.kt:84)
com.github.kittinunf.fuel.core.DeserializableKt.response(Deserializable.kt:168)
com.github.kittinunf.fuel.core.requests.DefaultRequest.responseString(DefaultRequest.kt:475)
com.a.b.c.d.model.Cluster.createSnapshot(Cluster.kt:67)
com.a.b.c.d.model.Cluster.createSnapshot$default(Cluster.kt:57)
com.a.b.c.d.model.ClusterKt.main(Cluster.kt:85)
Caused by: HTTP Exception 400 Bad Request
com.github.kittinunf.fuel.core.FuelError$Companion.wrap(FuelError.kt:86)
Caused by: com.github.kittinunf.fuel.core.HttpException: HTTP Exception 400 Bad Request
com.github.kittinunf.fuel.core.requests.RequestTask.prepareResponse(RequestTask.kt:35)
com.github.kittinunf.fuel.core.requests.RequestTask.call(RequestTask.kt:47)
com.github.kittinunf.fuel.core.requests.RequestTask.call(RequestTask.kt:14)
com.github.kittinunf.fuel.core.DeserializableKt.response(Deserializable.kt:166)
com.github.kittinunf.fuel.core.requests.DefaultRequest.responseString(DefaultRequest.kt:475)
com.a.b.c.d.model.Cluster.createSnapshot(Cluster.kt:67)
com.a.b.c.d.model.Cluster.createSnapshot$default(Cluster.kt:57)
com.a.b.c.d.model.ClusterKt.main(Cluster.kt:85)
How can I see the actual error message? Thanks in advance.
I solved my problem by looking at response.data which is a bytes array. Converting it to string by String(response.data) I could see the error message.
It's really quite annoying that the default exception doesn't just print this.
I struggled with the generics on this one to pull the handler into its own function, so I thought I share my complete code here.
fun <T> genericErrorHandler(response: Response, result: Result.Failure<Exception>): T {
println("Request to url ${response.url} failed, server returned:")
println(String(response.data))
throw result.getException()
}
private fun someRequest(url: String, jsonBody: String): SomeDataFormatYouExpectOnSuccess {
val (_, response, result) = url.httpPost().header("Content-Type", "application/json; utf-8")
.header("Authorization", "") // adding some headers
.jsonBody(jsonBody)
.responseString()
return when (result) {
is Result.Failure -> genericErrorHandler(response, result)
is Result.Success -> {
val data = result.get()
gson.fromJson(data, SomeDataFormatYouExpectOnSuccess::class.java)
}
}
}
Getting Error: Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author]
I have the "w_organization_social" permission in my app. I'm successfully getting the access token.
Can anyone help me what's going wrong?
Url: https://api.linkedin.com/v2/ugcPosts
Body:
{
"author":"urn:li:person:<id>",
"lifecycleState":"PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text":"Hello world"
},
"shareMediaCategory": "VIDEO",
"media":[{
"status":"READY",
"description": {
"text":"hello world"
},
"media":"urn:li:digitalmediaAsset:<asset_id>",
"title":{
"text":"hello world"
}
}]
}
},
"visibility":{
"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"
}
}
Response:
{
"serviceErrorCode" : 100,
"message" : "Field Value validation failed in REQUEST_BODY: Data Processing Exception while processing fields [/author]",
"status" : 403
}
While getting access token, make sure that you pass r_liteprofile and w_member_social permissions in scope.
Then you have to send a GET request to https://api.linkedin.com/v2/me, to get the Lite Profile and you will get the ID from the response.
Use the ID you got from Lite Profile to generate Person URN,
eg: "urn:li:person:<ID>"
Inside my server, I that checks some data from the database and throws an error when it's not valid. I have it like so:
//SERVER CODE:
Meteor.methods({
send: function (prefix, number, content) {
Future = Npm.require('fibers/future');
var future = new Future();
//do some validation
myReference.doSomething({
number: number,
content: content
}, function(error) {
if(error) {
future.throw("Cannot send at this time.");
} else {
future.return("SUCCESS");
}
});
return future.wait();
}
});
In the client side, I would like to get the message "Cannot send at this time." inside future.throw("Cannot send at this time.");. Hopefully I could show it inside an alert. How do I do that?
Currently, this is what I'm trying and I keep getting some undefined error.
//CLIENT CODE
Meteor.call("send", prefix, number, content, function(err, result) {
if(err) {
console.log(err);
alert(err);
} else {
console.log("SUCCESSFULLY SENT. ", result);
}
});
This is the error I get when trying to get the error message:
errorClass: Internal server error [500]
{
error: 500,
reason: "Internal server error",
details: undefined, message: "Internal server error [500]",
errorType: "Meteor.Error"…}
details: undefined
error: 500
errorType: "Meteor.Error"
message: "Internal server error [500]"reason:
"Internal server error"stack: (...)get
stack: function () { [native code] }set stack:
function () { [native code] }__proto__: Middle
How do I get the error message that I threw from future?
Use it like that: return future.throw(new Meteor.Error(400, 'ololo'))
future.throw expects an Meteor.Error instance that in it's turn contains error message itself and additionally http response code. So 400 is Bad Request response code in that case and ololo is error message.
return isn't actually necessary here but I do it every time just to be sure I don't call any code after failure.