I am using simpldb and am trying to save rahul' mehta in simpledb but it is giving me error below :
Code :
function htmlEscape(text) {
return text.replace(/&/g,'&').
replace(/</g,'<').
replace(/"/g,'"').
replace(/'/g,''');
}
console.log(params.filename);
if (params.filename!=undefined) params.filename=htmlEscape(params.filename);
console.log(sys.inspect(params));
sdb.putItem(domain, params.objectid, params, function( error ) {
});
Output :
rahul' mehta
{
filename: 'rahul' mehta',
}
Error :
{"event":"error","errno":"InvalidQueryExpression","message":"The specified query expression syntax is not valid.","queueno":7}
Why this error is coming , how can i solve it ?
This error is because you are trying to run Amazon SimpleDB SELECT Query and syntax of that query is wrong. This may be because in query -- Attribute Value -- must be unclosed with single quotes i.e. 'Attribute Value', and again if -- Domain Name -- and -- Attribute Name -- contains any special characters then they must be unclosed with acute i.e Domain Name OR Attribute Name. I think you are able to save rahul' mehta but when you are trying to get that saved attribute-value, you are getting this error. http://www.sdbexplorer.com/
Related
I'm using Terraform v0.14.4 with GCP. I have a Cloud Run service that won't be managed with Terraform (it might exist or not), and I want to read its url.
If the service exists this works ok:
data "google_cloud_run_service" "myservice" {
name = "myservice"
location = "us-central1"
}
output "myservice" {
value = data.google_cloud_run_service.myservice.status[0].url
}
But if it doesn't exist, I can't get it to work!. What I've tried:
data.google_cloud_run_service.myservice.*.status[*].url
status is null
length(data.google_cloud_run_service.myservice) > 0 ? data.google_cloud_run_service.myservice.*.status[0].url : ""
Tried with join("", data.google_cloud_run_service.myservice.*.status)
I get this error: data.google_cloud_run_service.myservice is object with 9 attributes
coalescelist(data.google_cloud_run_service.myservice.*.status, <...>)
It just returns [null], and using compact over the result gets me a Invalid value for "list" parameter: element 0: string required.
Any ideas?
It seems like you are working against the design of this data source a little here, but based on the error messages you've shown it seems like the behavior is that status is null when the requested object doesn't exist and is a list when it does, and so you'll need to write an expression that can deal with both situations.
Here's my attempt, based only on the documentation of the resource along with some assumptions I'm making based on the error message you included:
output "myservice" {
value = (
data.google_cloud_run_service.myservice.status != null ?
data.google_cloud_run_service.myservice.status[0].url :
null
)
}
There is another potentially-shorter way to write that, relying on the try function's ability to catch dynamic errors and return a fallback value, although this does go against the recommendations in the documentation in that it forces an unfamiliar future reader to do a bit more guesswork to understand in which situations the expression might succeed and which it might return the fallback:
output "myservice" {
value = try(data.google_cloud_run_service.myservice.status[0].url, null)
}
I have a text index on a collection. I added a language field to my documents, and all of a sudden started receiving a bunch of "language override unsupported: <LANG>" errors. Apparently language is a magical field when you have a text index.
How do I make mongo not throw an error if the language is unsupported?
It doesn't matter to me if a language is unsupported. I want my insert operation to succeed, regardless if the language is supported or not.
The insert operation:
// This should succeed regardless if suggestion.language is an unsupported language
// I don't want to wrap this in a try/catch, and have to retry on error.
addSuggestion (suggestion) {
const suggCol = db.get().collection('suggestions')
return suggCol.insertOne(suggestion)
},
How I create my index
// Create a text index, on the "text" property.
// TODO: Mongo throws error if suggestion.language contains an
// unsupported language. Override the language for now.
db.collection('suggestions').createIndex({ text: 'text' }, { language_override: 'dummyVal' })
To avoid the error for now, I'm ignoring the text index by setting { language_override: 'dummyVal' }. In the future, I would like to use the language_override.
This is a feature and you seem to have already arrived at the correct solution - language_override.
I am trying to upload a JSON-object to Google Firestore.
When setting the Object to a Firestore Document my code throws the following Error:
Error: Value for argument "data" is not a valid Firestore document.
Cannot use "undefined" as a Firestore value
(found in field audit.`20`.requests.`0`.lrEndTimeDeltaMs).
Now the first thing I did was log the Object right before the upload to check for undefined values:
console.log(JSON.stringify(resultsToUpload));
return database
.collection("foo1")
.doc("bar1")
.set(resultsToUpload);
Not only are all values defined in the object, but the mentioned field audit.`20`.requests.`0`.lrEndTimeDeltaMs does not even exist:
resultsToUpload = {
"audit":{
"20":{
"ronaldScore":3,
"id":"network-requests",
"requests":[
{
"url":"https://www.example.com/",
"startTime":0,
"endTime":62.16699999640696,
"transferSize":15794,
"resourceSize":78243,
"statusCode":200,
"mimeType":"text/html",
"resourceType":"Document"
}
]
}
}
}
The data comes from a Google Lighthouse Audit.
Calculating the UTF-8 string length of the stringified JSON objects results in a size of 30 MB.
1) All values are defined (some are null, which should not be a problem).
2) The mentioned field does not even exist in the JSON.
My question is: How can this happen? How can a field just appear?
Also: How would I fix this issue?
using JSON.stringify on a Javascript-Object hides all "undefined" values (as well as their keys) and then stringifies what is left.
That is because JSON does not have such a thing as "undefined".
So the log showed a fully defined JSON, even though the actual JS-Object did contain "undefined" values.
I have a json which has the a particular format, I wanted to extract data from it, but it contains ':' in its key value which is giving error while printing
metadata:
{
'A:B':'string'
}
I have tried to take it in another varibale stills it gives error:
text='A'+':'+'B';
console.log(metadata.text);
//console.log(metadata.A:B);
You can simply use jsonVariableName["ObjectName"] instead of sonVariableName.ObjectName
var metadata = {
'A:B':'string'
};
console.log(metadata["A:B"]);
Also I found you mention code as:
metadata:{...}
Which I think will be:
metadata = {...}
This is very odd... I'm using populate() with a ref to fill in an array within my schema, but then the properties are inaccessible. In other words, the schema is like this:
new Model('User',{
'name': String,
'installations': [ {type: String, ref: 'Installations'} ],
'count': Number,
}
Of course, Insallations is another model.
Then I find & populate a set of users...
model.find({count: 0}).populate('installations').exec( function(e, d){
for(var k in d)
{
var user = d[k];
for(var i in user.installations)
{
console.log(user.installations[i]);
}
}
} );
So far so good! I see nice data printed out, like this:
{ runs: 49,
hardware: 'macbookpro10,1/x86_64',
mode: 'debug',
version: '0.1' }
However, if I try to actually ACCESS any of those properties, they're all undefined! For example, if I add another console log:
console.log(user.installations[i].mode);
Then I see "undefined" printed for this log.
If I try to operate on the object, like this:
Object.keys(user.installations[i]).forEach(function(key) { } );
Then I get a typical "[TypeError: Object.keys called on non-object]" error, indicating that user.installations[i] is not an object (even though it is outputted to the console as if it were). So, I even tried something ugly like...
var install = JSON.parse(JSON.stringify(user.installations[i]));
console.log(install, install.mode);
And, again, the first output (install) is a nice object containing the property 'mode'... but the 2nd output is undefined.
What gives?
Finally, I solved this...
I tried doing a console.log(typeof user.installations[i]); and got "string" as the output. This seemed odd, given that printing the object directly created console output (above) that looked like a normal object, not a string. So, I tried doing a JSON.parse(); on the object, but received the error "SyntaxError: Unexpected token r"
Finally, I realized what was going on. The "pretty console output" I described above was the result of a string formatted with \n (newlines). I had not expected that, for whatever reason. The JSON.parse() error is due to the fact that there is a known necessity with the node.js parser when attempting to parse object keys without quotations; see the SO question here:
Why does JSON.parse('{"key" : "value"}') do just fine but JSON.parse('{key : "value"}') doesn't? .
Specifically, note that the JSON parser in my case is failing on the character 'r', the fist character of "runs," which is the first key in my JSON string (above). At first I was afraid I needed to get a custom JSON parser, but then the problem hit me.
Look back to my original schema. I used a String-type to define the installation ref, because the array field was storing the installations's _id property as a String. I assume the .populate() field is converting the object to a String on output.
Finally, I looked at the Mongoose docs a little closer and realized I'm supposed to be referencing the objects based upon Schema.ObjectID. This explains everything, but certainly gives me some fixing to do in my schemas and code elsewhere...