GORM standalone: no updateOne() with maps - mongodb

In my good'ol grails (3.1.x) app I have lines like
ModuleState.collection.updateOne(
[ compositeKey:ck ],
[ $set:[ compositeKey:ck, dateUpdated:new Date(), online:true ] ],
[ upsert:true ] )
In my grails-free app with GORM standalone:
compile 'org.grails:grails-datastore-gorm-mongodb:6.0.4.RELEASE'
this line throws an exception
groovy.lang.MissingMethodException: No signature of method: com.mongodb.MongoCollectionImpl.updateOne() is applicable for argument types: (java.util.LinkedHashMap, java.util.LinkedHashMap, java.util.LinkedHashMap) values: [[compositeKey:111], [$set:[...]], ...]
Possible solutions: updateOne(org.bson.conversions.Bson, org.bson.conversions.Bson), updateOne(org.bson.conversions.Bson, org.bson.conversions.Bson, com.mongodb.client.model.UpdateOptions)
so, the new map-consuming methods are not injected.
Any way to fix it and make GORM great again?

You need to add org.grails:grails-datastore-gorm-mongodb-ext:6.0.4.RELEASE to your classpath

Related

Flow Enums correctly parsed but not transformed

In my React app, I'm trying to migrate from my "old school" JS enums to Flow Enums:
https://flow.org/en/docs/enums/
(I think) I've done everything listed here:
https://flow.org/en/docs/enums/enabling-enums/
eslint and flow check are both happy (zero error) and the enums work as expected when I type code.
But when I start my app, they are not transformed and I get this:
ERROR in ./src/types.js
Module build failed (from ../../node_modules/babel-loader/lib/index.js):
SyntaxError: C:\foo\src\types.js: Unexpected token, expected "{" (16:7)
14 | |};
15 |
> 16 | export enum FooEnum {
| ^
17 | On,
18 | Off,
19 | Default
at instantiate (C:\foo\node_modules\#babel\parser\lib\index.js:72:32)
at constructor (C:\foo\node_modules\#babel\parser\lib\index.js:366:12)
at FlowParserMixin.raise (C:\foo\node_modules\#babel\parser\lib\index.js:3453:19)
at FlowParserMixin.unexpected (C:\foo\node_modules\#babel\parser\lib\index.js:3491:16)
at FlowParserMixin.parseExport (C:\foo\node_modules\#babel\parser\lib\index.js:16044:16)
at FlowParserMixin.parseExport (C:\foo\node_modules\#babel\parser\lib\index.js:6170:24)
at FlowParserMixin.parseStatementContent (C:\foo\node_modules\#babel\parser\lib\index.js:14893:27)
at FlowParserMixin.parseStatement (C:\foo\node_modules\#babel\parser\lib\index.js:14777:17)
at FlowParserMixin.parseStatement (C:\foo\node_modules\#babel\parser\lib\index.js:5951:24)
at FlowParserMixin.parseBlockOrModuleBlockBody (C:\foo\node_modules\#babel\parser\lib\index.js:15420:25)
Package-wise, all of them are in their latest version and I've installed:
babel-plugin-transform-flow-enums
eslint-plugin-ft-flow
flow-enums-runtime
My Babel config is:
"babel": {
"plugins": [
"#babel/plugin-proposal-class-properties",
[
"#babel/plugin-syntax-flow",
{
"enums": true
}
],
"babel-plugin-transform-flow-enums"
],
"presets": [
"#babel/preset-env",
"#babel/preset-flow",
"#babel/preset-react"
]
},
Also, calling Babel from a command line correctly transforms the enum. I'm using this command:
npx babel src/types.js
What could I have missed?
So, after struggling for hours, I eventually found out that
react-app-rewired was messing up with my Babel plugins.
I ended up installing customize-cra, which allowed me to explicitely use my Babel config:
const {useBabelRc, override} = require('customize-cra');
module.exports = override(
useBabelRc()
);

While deploying in serverless Framework im geeting this issue? Deprecation Warning?

Deprecation warning: CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options: - ServerlessPlugin for "out" - ServerlessOffline for "apiKey", "corsAllowHeaders", "corsAllowOrigin", "corsDisallowCredentials", "corsExposedHeaders", "disableCookieValidation", "enforceSecureCookies", "hideStackTraces", "host", "httpPort", "httpsProtocol", "lambdaPort", "noPrependStageInUrl", "noAuth", "ignoreJWTSignature", "noTimeout", "prefix", "printOutput", "resourceRoutes", "useChildProcesses", "useWorkerThreads", "websocketPort", "webSocketHardTimeout", "webSocketIdleTimeout", "useDocker", "layersDir", "dockerReadOnly", "functionCleanupIdleTimeSeconds", "allowCache", "dockerHost", "dockerHostServicePath", "dockerNetwork" - WarmUp for "warmers" Please report this issue in plugin issue tracker.
Upgrading the "serverless-offline" module to "^8.5.0" fixed my problem
// package.json
"devDependencies": {
"serverless-offline": "^8.5.0"
},
Let me know if this solves your problem.

Encountered unsupported property ComparisonOperator

Cloudformation stack throws Error "Encountered unsupported property Comparison Operator" , while creating an AWS::CloudWatch::Alarm using cloudformation.
As per AWS documentation ComparisionOperator value GreaterThanOrEqualtoThreshold is valid.
I use AWSTemplateFormatVersion as 2010-09-09
Any help would be appreciated :)
"CPUHighAlarm":{
"Type":"AWS::CloudWatch::Alarm",
"Properties":{
"AlarmDescription":"High CPU utilization",
"MetricName":"CPUUtilization",
"Namespace":"AWS/EC2",
"AlarmActions":[{"Ref":"asgScaleOut"}],
"ComparisionOperator": "GreaterThanOrEqualtoThreshold",
"EvaluationPeriods": "1",
"Threshold": "70",
"Period":"180",
"Statistic": "Average",
"Dimensions": [
{
"Name": "AutoScalingGroupName",
"Value": {
"Ref": "asg"
}
}
]
}
},
Just a typo. Should be ComparisonOperator instead of ComparisionOperator.
The CloudFormation Linter can help you catch these quicker and the Visual Studio Code extension can help prevent typos with autocompletion:
E3002: Invalid Property Resources/CPUHighAlarm/Properties/ComparisionOperator
Maybe it's case sensitive. Try GreaterThanOrEqualToThreshold.

StreamEnabled table property causes Serverless failure

I'm using Serverless to deploy my AWS cloudformation stack. On one of my tables, I enable streams via "StreamEnabled": true. When this is enabled, I get an error on deployment: Encountered unsupported property StreamEnabled.
If I remove the property, I get a validation exception: ValidationException: Stream StreamEnabled was null.
I found a git issue that was addressed and apparently fixed (here), but after upgrading to v1.3, I'm still getting the same errors on deployment.
Can anyone lend insight as to what the issue may be?
It is enabled by default. You can check it from shell:
aws dynamodbstreams list-streams
{
"Streams": [
{
"TableName": "MyTableName-dev",
"StreamArn": "arn:aws:dynamodb:eu-west-2:0000000000000:table/MyTableName-dev/stream/2018-10-26T15:06:25.995",
"StreamLabel": "2018-10-26T15:06:25.995"
}
]
}
And:
aws dynamodbstreams describe-stream --stream-arn "arn:aws:dynamodb:eu-west-2:00000000000:table/MyTableName-dev/stream/2018-10-26T15:06:25.995"
{
"StreamDescription": {
"StreamLabel": "2018-10-26T15:06:25.995",
"StreamStatus": "ENABLED",
"TableName": "MyTableName-dev",
"Shards": [
{
"ShardId": "shardId-000000000000000-0000000f",
"SequenceNumberRange": {
"StartingSequenceNumber": "00000000000000000000000"
}
}
],
"CreationRequestDateTime": 1540566385.987,
"StreamArn": "arn:aws:dynamodb:eu-west-2:0000000000000000:table/MyTableName-dev/stream/2018-10-26T15:06:25.995",
"KeySchema": [
{
"KeyType": "HASH",
"AttributeName": "application_id"
}
],
"StreamViewType": "KEYS_ONLY"
}
}
It is not a solution, but found that fact I realized that I don't have an issue.

Illegal character in query at index 40: facebook

Sorry, I am reformulating the question; I was so frustrated by this Error that I posted the question in a snap.
I am trying to use camel-facebook component and using very simple route that figures as such in the blueprint.xml file:
from uri="facebook://me?oAuthAppId={{oAuthAppId}}&oAuthAppSecret={{oAuthAppSecret}}&oAuthAccessToken={{oAuthAccessToken}}&consumer.delay=86400000"/>
I am using :
Red Hat JBoss Developer Studio
Version: 10.1.0.GA
Actually I see the bundle started :
[ 348] [Active ] [Created ] [ ] [ 80] MyApp [fbdemo] (1.0.0.SNAPSHOT)
Also :
[ 333] [Active ] [ ] [ ] [ 50] camel-facebook (2.17.0.redhat-630187)
Perhaps I have the error mentioned above, I put XXXXXXXXX for oAuth*.
2017-02-14 16:02:16,128 | ERROR | 68)-192.168.56.1 | BlueprintCamelContext | 234 - org.apache.camel.camel-blueprint - 2.17.0.redhat-630187 | Error occurred during starting Camel: CamelContext(blueprintContext) due Failed to create route fbRoute: Route(fbRoute)[[From[facebook://me?oAuthAppId={{oAuthAppId}}... because of Failed to resolve endpoint: facebook://me?oAuthAppId=XXXXXXXXXXXXXX
&oAuthAppSecret=XXXXXXXXXXXXXXXXXXXXXX&oAuthAccessToken=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&consumer.delay=86400000 due to: Illegal character in query at index 40: facebook://me?oAuthAppId=XXXXXXXXXXXXXXXXXXXXXXX
&oAuthAppSecret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&oAuthAccessToken=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&consumer.delay=86400000
org.apache.camel.FailedToCreateRouteException: Failed to create route fbRoute: Route(fbRoute)[[From[facebook://me?oAuthAppId={{oAuthAppId}}... because of Failed to resolve endpoint: facebook://me?oAuthAppId=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
&oAuthAppSecret=XXXXXXXXXXXXXXXXXXXXXXXXXXXX&oAuthAccessToken=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&consumer.delay=86400000 due to: Illegal character in query at index 40: facebook://me?oAuthAppId=XXXXXXXXXXXXXXXX
Shall the oAuthAccessToken be the Application AccesToken or User AccessToken that I get from Facebook Graph Explorer. Note that I don`t have any special character in code secret only a | ( pipe) in case the AccessToken is the Appli AccessToken not User AccessToken. How to figure the index 40.
Thank you very much
If you are using xml then you need to check that all "&" symbols are encoded as "&" so it will looks like:
<from url="facebook://me?oAuthAppId=XXXXXXXXXXXXX&oAuthAppSecret=XXXXXXXXXXXXXXXXXXXXXXXXX&oAuthAccessToken=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&consumer.delay=86400000" />