jfrog artifactory "invalid character '"' after object key:value pair" - repository

So I have this spec file in artifactory to remove folders (with artifacts inside) older than 3 months in more than one repository (3 in this example).
{
"files": [{
"aql": {
"items.find": {
"$or": [{
"$and": [{
"repo": "repo1",
"path": "com/domain/repo1",
"created": {
"$before": "3mo"
}
"type": "folder",
"name": {"$match":"20*"}
}],
"$and": [{
"repo": "repo2",
"path": "com/domain/repo2",
"created": {
"$before": "3mo"
}
"type": "folder",
"name": {"$match":"20*"}
}],
"$and": [{
"repo": "repo3",
"path": "com/domain/repo3",
"created": {
"$before": "3mo"
}
"type": "folder",
"name": {"$match":"20*"}
}]
}]
}
}
}]
}
But I´m getting: [Error] invalid character '"' after object key:value pair
How can I tell what is the (") that is causing the error? is not quite descriptive the output like in some other languajes that tells you the line number at least.
On the other hand, if I use following spec for a single repository, it works like a charm.
thank you!
{
"files": [{
"aql": {
"items.find": {
"repo": "repo5",
"path": "com/domain/repo5",
"created": {
"$before": "3mo"
},
"type":"folder",
"name": {"$match":"20*"}
}
}
}]}

You are missing a comma after all of the "created" key/value pairs:
"created": {
"$before": "3mo"
} <-- missing a comma here
"type": "folder",
Please notice that your working example has the comma in the right place.

Related

Search including special characters in MongoDB Atlas

I faced with the issue when I try to search for several words including a special character (section sign "§").
Example: AB § 32.
I want all words "AB", "32" and symbol "§" to be included in found documents.
In some cases document can be found, in some not.
If my document contains the following text then search finds it:
Lagrum: 32 § 1 mom. första stycket a) kommunalskattelagen (1928:370) AB
But if document contains this text then search doesn't find:
Lagrum: 32 § 1 mom. första stycket AB
For symbol "§" I use UT8-encoding "\xc2\xa7".
Index uses "lucene.swedish" analyzer.
"Content": [
{
"analyzer": "lucene.swedish",
"minGrams": 4,
"tokenization": "nGram",
"type": "autocomplete"
},
{
"analyzer": "lucene.swedish",
"type": "string"
}
]
Query looks like:
{
"index": "test_index",
"compound": {
"filter": [
{
"text": {
"query": [
"111111111111"
],
"path": "ProductId"
}
},
],
"must": [
{
"autocomplete": {
"query": [
"AB"
],
"path": "Content"
}
},
{
"autocomplete": {
"query": [
"\xc2\xa7",
],
"path": "Content"
}
},
{
"autocomplete": {
"query": [
"32"
],
"path": "Content"
}
}
],
},
"count": {
"type": "lowerBound",
"threshold": 500
}
}
The question is what is wrong with the search and how can I get a correct result (return both above mentioned documents) ?
Focusing only on the content field, here is an index definition that should work for your requirements. The docs are here. Let me know if this works for you.
{
"mappings": {
"dynamic": false,
"fields": {
"content": [
{
"type": "autocomplete",
"tokenization": "nGram",
"minGrams": 4,
"maxGrams": 7,
"foldDiacritics": false,
"analyzer": "lucene.whitespace"
},
{
"analyzer": "lucene.swedish",
"type": "string"
}
]
}
}
}

TextMate grammar - clashing multi-line captures

I have the following syntax:
test: name {
param_name: value
another_param: value2
test: [12, "asd"]
test2: [
"test__",
"test3"
]
}
My logic here is as follows:
Detect scopes as multi-line match
"begin": "([a-z_]+)\\s?:\\s?([a-z_\\+]+)?\\s?(\\{)",
"end": "(\\})",
In the patterns section of the above, add parameters with multiline matching
"begin": "(?!sql)([a-z\\_]*)\\s?:",
"end": "(?<=\\n)",
And then in the patterns of that I have array
"begin": "\\[",
"end": "\\]",
The problem is that test: [12, "asd"] is correctly defined as
test - parameter name
[12, "asd"] - parameter value + array
but I can't get it to work on the multi-line value. It only recognises the opening [ as array.
At first I thought I understood the reason why. The parameters finishes when it sees a new line, hence the second line of an array will not be matched. So I added array to the main scope pattern and that's when my understanding ends.
Full file:
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "QQQL",
"patterns": [
{"include": "#scopes"},
{"include": "#parameters"}
],
"repository": {
"scopes": {
"name": "source.qqql.scope",
"begin": "([a-z_]+)\\s?:\\s?([a-z_\\+]+)?\\s?(\\{)",
"end": "(\\})",
"patterns": [
{"include": "#scopes"},
{"include": "#array"},
{"include": "#parameters"}
]
},
"parameters": {
"name": "source.qqql.parameter",
"begin": "(?!sql)([a-z\\_]*)\\s?:",
"end": "(?<=\\n)",
"beginCaptures": {
"1": {
"name": "source.qqql.parameter.name"
}
},
"patterns": [
{"include": "#array"},
{
"name": "source.qqql.parameter.value",
"match": "(.*)",
"captures": {
"1": {
"patterns": [
{"include": "#array"}
]
}
}
}
]
},
"array": {
"name": "source.qqql.array",
"begin": "\\[",
"end": "\\]",
"patterns": [
{"include": "#strings"},
{
"name": "source.qqql.array.delimiter",
"match": "\\,"
}
]
}
},
"scopeName": "source.qqql"
}
What I expected is that the inclusion of array in scopes would solve the problem but somehow it doesn't.

Not able to match same json which has mismatch in indexes of array of objects (Karate) [duplicate]

This question already has an answer here:
Is there a simple match for objects containing array where the array content order doesn't matter?
(1 answer)
Closed 1 year ago.
Trying to match two jsons, but getting test fails. Well, both jsons are the same but objects indexes inside the array are not same. I think should not make any difference. Following are two jsons:
This is the code line: And match response contains ScenarioModelResponse where
**response : **
{
"relationships": [
{
"sourceId": "36",
"targetId": "149",
"type": "Reid Enright"
}
],
"modelId": "027f93d1-ef9e-4f1e-b2c4-684436c5b18a",
"elements": [
{
"externalRefId": "36",
"attributes": {
"jsonPbject": "Reid Enright"
},
"id": "057f7b7e-11b9-4779-97c0-67485153c285",
"type": "Rocky Shore"
},
{
"externalRefId": "149",
"attributes": {
"jsonPbject": "Ben Lyon"
},
"id": "325b989e-b299-4cfc-86b5-0813106da38e",
"type": "Claire Voyance"
}
]
}
ScenarioModelResponse :
{
"relationships": [
{
"sourceId": "36",
"targetId": "149",
"type": "Reid Enright"
}
],
"modelId": "027f93d1-ef9e-4f1e-b2c4-684436c5b18a",
"elements": [
{
"externalRefId": "149",
"attributes": {
"jsonPbject": "Ben Lyon"
},
"id": "325b989e-b299-4cfc-86b5-0813106da38e",
"type": "Claire Voyance"
},
{
"externalRefId": "36",
"attributes": {
"jsonPbject": "Reid Enright"
},
"id": "057f7b7e-11b9-4779-97c0-67485153c285",
"type": "Rocky Shore"
}
]
}
This the error I am getting after execution :
$.elements[0].externalRefId | not equal (STRING:STRING)
'149'
'36'
The arrays are NOT the same. This can be solved in 2 lines:
* match response.relationships == expected.relationships
* match response.elements contains only expected.elements
For a detailed explanation, refer:
https://stackoverflow.com/a/65939070/143475
https://stackoverflow.com/a/55710769/143475

Forwading URL Through Cloudflare API

I'm trying to create a page rule using Cloudflare's API to forward http to https. Unfortunately, I don't think the documentation is 100% clear on how to do this. Here is the JSON object I'm currently passing to the POST body:
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "http://exampletest.com/*"
}
}
],
"actions": [{
"id": "forwarding_url",
"value": "https://exampletest.com/$1"
}]
}
and here is the message I'm getting back:
{
"success": false,
"errors": [
{
"code": 1004,
"message": "Page Rule validation failed: See messages for details."
}
],
"messages": [
{
"code": 1,
"message": ".settings[0].url: This value should not be blank.",
"type": null
},
{
"code": 2,
"message": ".settings[0].statusCode: This value should not be blank.",
"type": null
}
],
"result": null
}
So it seems like I need to have a settings object somewhere, but any way I try to add the settings, I'm getting the same message. Does anyone know what I'm doing wrong here? Here is Cloudflare's Documentation on the subject. Not sure if I might be missing something:
https://api.cloudflare.com/#page-rules-for-a-zone-create-page-rule
Actually, just figured this one out. It looks like this is the correct format:
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "http://exampletest.com/*"
}
}
],
"actions": [
{
"id": "forwarding_url",
"value": {
"url": "https://www.exampletest.com/$1",
"status_code": 301
}
}
]
}
You have to set a parameter - "status":"active" to actually activate the page rule or else you're just creating an inactive rule.
Cloudflare sets this as an optional parameter, but it is needed to activate the rule.
The updated version of this answer goes like this:
{
"targets": [
{
"target": "url",
"constraint": {
"operator": "matches",
"value": "http://exampletest.com/*"
}
}
],
"actions": [
{
"id": "forwarding_url",
"value": {
"url": "https://www.exampletest.com/$1",
"status_code": 301
}
}
],
"status": "active"
}

How to update existing Knowledgebase using QnA Maker API v4.0?

I've successfully created my Knowledgebase using API.
But I forgot to add some alternative questions and metadata for one of the pairs.
I've noticed PATH method in the API to update the Knowledebase, so updating kb is supported.
I've created a payload which looked like this:
{
"add": {
},
"delete": {
},
"update": {
"qnaList": [
{
"id": 1,
"answer": "Answer",
"source": "link_to_source",
"questions": [
"Question 1?",
"Question 2?"
],
"metadata": [
{
"name": "oldMetadata",
"value": "oldMetadata"
},
{
"name": "newlyAddedMetaData",
"value": "newlyAddedMetaData"
}
]
}]}
}
I get back the following response HTTP 202 Accepted:
{
"operationState": "NotStarted",
"createdTimestamp": "2018-05-21T07:46:52Z",
"lastActionTimestamp": "2018-05-21T07:46:52Z",
"userId": "user_uuid",
"operationId": "operation_uuid"
}
So, looks like it worked. But in reality, this request doesn't take any affect.
When I check operation details, it returns me the following:
{
"operationState": "Succeeded",
"createdTimestamp": "2018-05-21T07:46:52Z",
"lastActionTimestamp": "2018-05-21T07:46:54Z",
"resourceLocation": "/knowledgebases/kb_uuid",
"userId": "user_uuid",
"operationId": "operation_uuid"
}
What am I doing wrong? And how should I update my kb via API properly?
Please help
I had the same problem, I discovered that it was necessary to have all the data of the json even if they were not used.
In your case you need "name" and "urls" in the "update" section and "Delete" in "update/qnaList/questions" section:
{
"add": {},
"delete": {},
"update": {
"name": "nameofKbBase", //this
"qnaList": [
{
"id": 2370,
"answer": "DemoAnswerEdit",
"source": "CustomSource",
"questions": {
"add": [
"DemoQuestionEdit"
],
"delete": [] //this
},
"metadata": { }
}
],
"urls": [] //this
}
}