Environment :
strongloop v6.0.3
node v6.11.2
loopback-cli#3.1.0
loopback-connector-grpc#1.1.0
Issue :
While creating a gRPC datasource, it doesn't read the proto file and throws an error
Error :
if (err) throw err;^
TypeError: Cannot initialize connector "loopback-connector-grpc": Cannot read property 'ns' of null
at Object.load (C:\Projects\GRPC\loopback-grpc\Server\node_modules\grpc\src\node\index.js:161:28)
at GRPCConnector.connect (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-connector-grpc\lib\grpc-connector.js:71:21)
at Object.initializeDataSource [as initialize] (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-connector-grpc\lib\grpc-connector.js:25:15)
at DataSource.setup (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-datasource-juggler\lib\datasource.js:416:19)
at new DataSource (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-datasource-juggler\lib\datasource.js:122:8)
at Registry.createDataSource (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback\lib\registry.js:360:12)
at Function.loopback.createDataSource (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback\lib\loopback.js:339:41)
at Object.module.exports [as func] (C:\Projects\GRPC\loopback-grpc\Server\server\boot\server.js:9:21)
at C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\lib\executor.js:316:22
at iterate (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\node_modules\async\lib\async.js:146:13)
at C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\node_modules\async\lib\async.js:157:25
at C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\lib\executor.js:321:9
at iterate (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\node_modules\async\lib\async.js:146:13)
at C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\node_modules\async\lib\async.js:157:25
at C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\lib\executor.js:321:9
at iterate (C:\Projects\GRPC\loopback-grpc\Server\node_modules\loopback-boot\node_modules\async\lib\async.js:146:13)
Reproduced steps :
I have just followed the documentation on loopback-connector-grpc official repository.
I tried it with code, it didn't create the datasource
var ds = loopback.createDataSource('grpc', {
connector: 'loopback-connector-grpc',
spec: 'note.proto',
});
also I tried with this :
"gRPCDataSource": {
"name": "gRPCDataSource",
"connector": "grpc",
"spec": "note.proto",
"security": {
"type" : "basic",
"username": "the user name",
"password": "thepassword"
}
but still has the same result.
I also used this command lb datasource followed the steps, downloaded the connector, again same error.
I found it, I just moved the proto file directory.
It has to be in the project root directory
Related
Im trying to create user with external claims, but something wents wrong.
I added my claims to scim2-schema-extension.config, to external claims and local claims, but API's response for my request is:
{
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:Error"
],
"detail": "Error in adding the user: testoviy22#mail.ru to the user store.",
"status": "500"
}
In logs i have
: ERR_13735_ELEMENT_FOR_OID_DOES_NOT_EXIST ATTRIBUTE_TYPE for OID comment does not exist!]; remaining name 'mail=testoviy22#mail.ru'
at java.naming/com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3280)
at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3205)
at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2996)
at java.naming/com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:452)
at java.naming/com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bind(ComponentDirContext.java:299)
at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(PartialCompositeDirContext.java:217)
at org.wso2.carbon.user.core.ldap.UniqueIDReadWriteLDAPUserStoreManager.persistUser(UniqueIDReadWriteLDAPUserStoreManager.java:312)
... 73 more
Local claim
External claim
Request sample:
{
"name": {
"familyName": "Zubenko",
"givenName": "Michael"
},
"password": "qwerty",
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
"comment": "test"
},
"userName": "testoviy22#mail.ru"
}
Seems you are using an LDAP server as your primary userstore, and that server doesn't support the attribute named "comment"
Refer to the note in https://is.docs.wso2.com/en/latest/references/extend/provisioning/extend-scim2-user-schemas/#map-the-custom-claim
You can use the word "customClaim" (or any other preferred word) as
the Mapped Attribute only when using a JDBC userstore because JDBC
userstores will automatically create a new attribute if it does not
already exist in the user store. However, If you are using LDAP or
Active Directory, you will have to use an attribute that exists in the
user store already.
Change the mapped attribute of the local claim to some valid attribute in the LDAP schema
I am trying to write "BatchPutItem" custom resolver, so that I can create multiple items (not more than 25 at a time), which should accept a list of arguments and then perform a batch operation.
Here is the code which I have in CusomtResolver:
#set($pdata = [])
#foreach($item in ${ctx.args.input})
$util.qr($item.put("createdAt", $util.time.nowISO8601()))
$util.qr($item.put("updatedAt", $util.time.nowISO8601()))
$util.qr($item.put("__typename", "UserNF"))
$util.qr($item.put("id", $util.defaultIfNullOrBlank($item.id, $util.autoId())))
$util.qr($pdata.add($util.dynamodb.toMapValues($item)))
#end
{
"version" : "2018-05-29",
"operation" : "BatchPutItem",
"tables" : {
"Usertable1-staging": $utils.toJson($pdata)
}
}
Response in the query console section:
{
"data": {
"createBatchUNF": null
},
"errors": [
{
"path": [
"createBatchUserNewsFeed"
],
"data": null,
"errorType": "MappingTemplate",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "Unsupported operation 'BatchPutItem'. Datasource Versioning only supports the following operations (TransactGetItems,PutItem,BatchGetItem,Scan,Query,GetItem,DeleteItem,UpdateItem,Sync)"
}
]
}
And the query is :
mutation MyMutation {
createBatchUNF(input: [{seen: false, userNFUserId: "userID", userNFPId: "pID", user NFPOwnerId: "ownerID"}]) {
items {
id
seen
}
}
}
Conflict detection is also turned off
And when I check cloud logs I found this error:
I was able to solve this issue by disabling DataStore for entire API.
When we create a new project/backend app using amplify console, and in data tab it asks us to enable data store so that we can start modelling our GraphQL api, that's the reason which enables versioning for the entire API, and it prevents batchWrite to execute.
So in order to solve this issue, we can follow these steps:
[Note: I am using #aws-amplify/cli]
$ amplify update api
? Please select from one of the below mentioned services: GraphQL
? Select from the options below: Disable DataStore for entire API
And then amplify push
This will fix this issue.
I'm going to try to set a disk label on a Google Compute Engine instance. Basically what is documentated here:
https://cloud.google.com/compute/docs/reference/rest/v1/disks/setLabels
Unfortunately also using the simple code provided by Google:
require_once __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('Google-ComputeSample/0.1');
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/cloud-platform');
$service = new Google_Service_Compute($client);
$project = 'my-project';
$zone = 'my-zone';
$resource = 'my-resource'; // here i set the disk name
$requestBody = new Google_Service_Compute_ZoneSetLabelsRequest();
$response = $service->disks->setLabels($project, $zone, $resource, $requestBody);
echo '<pre>', var_export($response, true), '</pre>', "\n";
?>
I always hit a 500 error:
Uncaught Google_Service_Exception: { "error": { "errors": [ { "domain": "global", "reason": "conditionNotMet", "message": "Labels fingerprint either invalid or resource labels have changed", "locationType": "header", "location": "If-Match" } ], "code": 412, "message": "Labels fingerprint either invalid or resource labels have changed" } }
where I suppose that I have the wrong label syntax. But in the label method, I have tried several syntax:
$requestBody->setLabels(array("mylabel"=>"1"));
$requestBody->setLabels(serialize(array("mylabel"=>"1")));
$requestBody->setLabels('"mylabel":"1"');
$requestBody->setLabels('{"mylabel":"1"}');
but none work. And nothing has changed (always 500 error with the same exception). What did I do wrong?
The error response you're receiving indicates that the labelFingerprint is wrong or not set. The request body should contain both the labels and the labelFingerprint and it looks like you're only setting the former:
{
"labels": {
string: string,
...
},
"labelFingerprint": string
}
The documentation you linked explains what the lableFingerprint is:
The fingerprint of the previous set of labels for this resource, used to detect conflicts. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels. Make a get() request to the resource to get the latest fingerprint.
A base64-encoded string.
Using the Loopback API explorer GET try this button with and without a filter, I am getting result no_usable_index:
{
"error": {
"statusCode": 400,
"name": "Error",
"message": "No index exists for this sort, try indexing by the sort fields.",
"error": "no_usable_index",
"reason": "No index exists for this sort, try indexing by the sort fields.",
"scope": "couch",
"request": {
"method": "post",
"headers": {
"content-type": "application/json",
"accept": "application/json"
},
"uri": "https://XXXXXX:XXXXXX#long-instance-id-number-bluemix.cloudant.com/aac_001_dev_db/_find",
"body": "{\"selector\":{\"loopback__model__name\":\"Center\"},\"use_index\":[\"lb-index-ddoc-Center\",\"lb-index-Center\"],\"sort\":[{\"id:string\":\"asc\"}]}"
},
"headers": {
"x-frame-options": "DENY",
"x-couch-request-id": "658ac2fdf8",
"date": "Tue, 06 Mar 2018 17:45:29 GMT",
"content-type": "application/json",
"cache-control": "must-revalidate",
"strict-transport-security": "max-age=31536000",
"x-content-type-options": "nosniff",
"x-cloudant-request-class": "query",
"x-cloudant-backend": "bm-cc-us-south-02",
"via": "1.1 lb1.bm-cc-us-south-02 (Glum/1.50.1)",
"statusCode": 400,
"uri": "https://XXXXXX:XXXXXX#long-instance-id-number-bluemix.cloudant.com/aac_001_dev_db/_find"
},
"errid": "non_200",
"description": "couch returned 400",
"stack": "Error: No index exists for this sort, try indexing by the sort fields.\n at Request._callback (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/cloudant-nano/lib/nano.js:248:15)\n at Request.self.callback (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/request/request.js:186:22)\n at emitTwo (events.js:106:13)\n at Request.emit (events.js:191:7)\n at Request.<anonymous> (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/request/request.js:1163:10)\n at emitOne (events.js:96:13)\n at Request.emit (events.js:188:7)\n at IncomingMessage.<anonymous> (/home/ubuntu/workspace/aac-001-api/node_modules/loopback-connector-cloudant/node_modules/cloudant/node_modules/request/request.js:1085:12)\n at IncomingMessage.g (events.js:292:16)\n at emitNone (events.js:91:20)\n at IncomingMessage.emit (events.js:185:7)\n at endReadableNT (_stream_readable.js:974:12)\n at _combinedTickCallback (internal/process/next_tick.js:80:11)\n at process._tickCallback (internal/process/next_tick.js:104:9)"
}
}
So I tried searching the lb3 documentation and found a cloudant-connector loopback.io / doc / en / lb3 / Cloudant-connector.html#index that describes the index feature as "To be updated". Hmmm, it is listed as a feature backlog.
Then I found [:link:][2] to the Model-definition-JSON-file which describes manually adding an indexes property. I tried:
// common -> models -> center.json
"indexes": {
"name_index": {"name": 1}
}, ...
I also tried the suggestion: "You can specify indexes at the model property level too, for example:"
"properties": {
"name": {
"type": "string",
"required": true,
"index": true // added this (but without the comment :)
}, ...
Alas, none of these attempts worked. I am still getting the error.
I have watched several off topic youtube videos of Loopback with MongoDB, but it is curious that there is not much available showing exactly how to get the Loopback-connector to work with Cloudant.
At this point I just want:
to GET the two test documents that have been POSTed using the the API explorer.
to know if these cloudant-connector GET methods work at all with lb version 3.
I added a mongodb datasource from the command line and edited the model-config.json file datsource parameter to point to the mongodb database, then performed a similar test. Added two documents with the POST button, then clicked try this with the GET button. It returns the two documents that were posted, just like in the youtube video tutorials.
Update with more clues
In the Cloudant dashboard query page there is a selector. If I make an errant change to the selector, Cloudant returns the error "no_usable_index". This means that the error message is not from Loopback, it is from Cloudant, but passed through Loopback.
Although the Loopback explorer has the same visual look and feel for both the mongo-connector and cloudant-connector; the url (REST) interface to the databases clearly must be different. I assumed that the POST, GET sequence of button clicks in the explorer that works to connect with Mongodb would work with Cloudant. It does not. Cloudant requires that a design document be available in the database to define valid queries.
I know for sure the database is accessible from the command line with:
$ curl $CLOUDANT_URL/$CLOUDANT_DATABASE
and with a design doc defined within the database
$ curl $CLOUDANT_URL/$CLOUDANT_DATABASE/_design/$DDOC_MEDICAL_CENTERS/_view/$VIEW_MEDICAL_CENTERS_TRUE
After much troubleshooting in the old version I found that the error went away when I changed
FROM loopback-connector-cloudant#1.2.5 3-Aug 2017
TO loopback-connector-cloudant#2.0.5 23-Mar 2018
by updating the package.json and running an npm update
I submitted a skill to Amazon for Alexa, and it failed certification due to intellectual property rights. Amazon suggested that I say the service is "for" the IP rights holder, so I modified the name and am now getting this error for everything I try to do.
{
"errorMessage": "Exception: TypeError: Cannot read property 'application' of undefined"
}
So far, I updated the Skill Name, Invocation Name, and Welcome Message. Is there something else I need to update or run on the dev portal to get this to work again?
Update: When I try to start the skill from the Alexa Development portal, I see this in the logs for
console.log("event.session.application.applicationId=" + event.session.application.applicationId);
{
"version": "1.0",
"session": {
"new": true,
"sessionId": "SessionId.8b65b2f5-0193-4307-9bef-88c116d9344b",
"application": {
"applicationId": "amzn1.echo-sdk-ams.app.5987b947-c8e9-4fc4-a0b8-2ba12c57ea59"
},
"attributes": null,
"user": {
"userId": "amzn1.ask.account.ABCDEFG" // masked my account value
}
},
"request": {
"type": "IntentRequest",
"requestId": "EdwRequestId.4d19f589-cdca-4303-99dc-0dc5cec781d2",
"timestamp": "2016-04-18T16:21:04Z",
"intent": {
"name": "DontKnowIntent"
}
}
}
The application ID matches the one supplied in the Alexa Development portal, so I don't think that's causing any issues. The property 'application' is only ever called after 'session', which clearly is defined. I don't know if the null attributes is causing an error. Maybe someone can look at a successful request?
Finally, here is my code: https://github.com/Shwheelz/alexa-skills-kit-js/blob/master/my_skills/pokemonTrivia/src/index.js
I have changed the name twice before on a node app and a Java 8 app. All I had to do was change the name (also changed invocation name) under the skill information. It worked first time out. Now my skill name did not update on alexa app once and did the other time. Since you are not certified, you may want to create the skill for scratch. This should only take about 5 or 10 mins. Just do not forget to change or add the new application Id of you lambda