How do I configure multiple pattern matchers for a VS Code Task? - vscode-problem-matcher

I'm trying to setup a Visual Studio Code CMake / Ninja project using GNU_ARM_10_2020-q4-major. With the base problem matcher set to "$gcc" it misses a lot messages and I can't figure out multiple patterns.
The following extract from the build output has two messages (saved to test.txt):
C:/Repos/ProjectN/ProjectN/Dave/Generated/ETH_LWIP/lwip/port/sys_arch.c: In function 'sys_sem_signal':
C:/Repos/ProjectN/ProjectN/Dave/Generated/ETH_LWIP/lwip/port/sys_arch.c:550:14: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
550 | osStatus_t ret;
| ^~~
c:/gnu_arm_10_2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: c:\repos\ProjectN\gfx-src\include/gfx_drawing.hpp:3203: undefined reference to `gfx::font::operator[](int) const'
The problem matcher (for testing) is set to:
{
"label": "build",
"type": "shell",
"command": "cmd /C type test.txt",
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": {
"fileLocation": "absolute",
"severity": "error",
"pattern": [
{
"regexp": "(.*):(\\d+):(\\d+): (.*): (.*)",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
},
{
"regexp": "(.*ld\\.exe): (.*):(\\d+): (.*)",
"file": 2,
"line": 3,
"message": 4
}
]
},
"group": {
"kind": "build",
"isDefault": true
}
}
The above does not match any lines.
If I remove the first pattern, the seconds works and I see an item in the Problems view. If I remove the second pattern, the first works and again I see an item in the Problems view.
Does anyone know what I'm doing wrong here?

Related

Using LogicApp to slice an array on indices

I'm trying to achieve something in LogicApp which I think should be quite easy to achieve, but I'm not managing it.
Say I have a variable from a previous step: 'https://sharepoint/sites/test-site/Documents/somereport.pdf'. From this string, I need to simply create two variables, the first one containing 'https://sharepoint/sites/test-site', the second one containing 'Documents/somereport.pdf'. Both to be used in subsequent steps.
To try and achieve this I try to use the following expressions:
join(slice(split(triggerBody()?['Title'], '/'), 0, 5), '/')
join(slice(split(triggerBody()?['Title'], '/'), 5), '/')
However, I get an error: 'The template language function 'slice' expects its first parameter to be of type string. The provided value is of type 'Array'..
This since the split results in an array. I've now learned that 'slice' is meant for strings, but is there any similar functionality for an array type? Or is there any other (simple) way to achieve this? This seems like it should be basic functionality but I cannot figure it out.
This can be achieved through few ways. If you are trying to use a functionality taking the result as array type then you can use something like below expression.
1. join(take(split(outputs('Compose')?['Title'][0], '/'), 5),'/')
2. join(take(skip(split(outputs('Compose')?['Title'][0], '/'),5), length(split(outputs('Compose')?['Title'][0], '/'))),'/')
However, As an alternative, below is another expression that satisfies your requirement if you are trying to use a functionality taking the result as string type.
1. slice(outputs('Compose')?['Title'][0],0,nthIndexOf(outputs('Compose')?['Title'][0],'/',5))
2. slice(outputs('Compose')?['Title'][0],add(nthIndexOf(outputs('Compose')?['Title'][0],'/',5),1),length(outputs('Compose')?['Title'][0]))
Below is my logic app
RESULTS:
Below is the code-view of my logic app
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": {
"Title": [
"https://sharepoint/sites/test-site/Documents/somereport.pdf"
],
"age": 30,
"name": "John"
},
"runAfter": {},
"type": "Compose"
},
"array_type_-_first_part": {
"inputs": "#join(take(split(outputs('Compose')?['Title'][0], '/'), 5),'/')",
"runAfter": {
"string_type__second_part": [
"Succeeded"
]
},
"type": "Compose"
},
"array_type_-_second_part": {
"inputs": "#join(take(skip(split(outputs('Compose')?['Title'][0], '/'),5), length(split(outputs('Compose')?['Title'][0], '/'))),'/')",
"runAfter": {
"array_type_-_first_part": [
"Succeeded"
]
},
"type": "Compose"
},
"string_type_-_first_part": {
"inputs": "#slice(outputs('Compose')?['Title'][0],0,nthIndexOf(outputs('Compose')?['Title'][0],'/',5))",
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "Compose"
},
"string_type__second_part": {
"inputs": "#slice(outputs('Compose')?['Title'][0],add(nthIndexOf(outputs('Compose')?['Title'][0],'/',5),1),length(outputs('Compose')?['Title'][0]))",
"runAfter": {
"string_type_-_first_part": [
"Succeeded"
]
},
"type": "Compose"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}

Slack API invalid_block

I'm building a simple slack bot and I am playing with the checkboxes element.
When I return the following from my API in a JSON response to a slash-command I get an error failed with the error "invalid_blocks", however, when I put this in the block-kit-builder it works perfectly (including "sending to slack" button)
Any ideas why this is failing when I run my slash command - and is it possible to see more detailed error messages from slack?
{
"blocks": [
{
"elements": [
{
"style": "primary",
"text": {
"emoji": true,
"text": "Create new TODO list",
"type": "plain_text"
},
"type": "button",
"value": "value"
},
{
"style": "primary",
"text": {
"emoji": true,
"text": "Help",
"type": "plain_text"
},
"type": "button",
"value": "value"
}
],
"type": "actions"
},
{
"text": {
"text": "Today",
"type": "mrkdwn"
},
"type": "section"
},
{
"elements": [
{
"initial_options": [
{
"text": {
"text": "Get Into the garden",
"type": "mrkdwn"
},
"value": "foo"
}
],
"options": [
{
"text": {
"text": "Get Into the garden",
"type": "mrkdwn"
},
"value": "foo"
}
],
"type": "checkboxes"
},
{
"style": "primary",
"text": {
"emoji": true,
"text": "Add new Task",
"type": "plain_text"
},
"type": "button",
"value": "value"
}
],
"type": "actions"
}
],
"type": "home"
}
I am using the Slack Web API. I was getting the similar error. After a lot of looking around, here's how I solved it.
import json
blocks = [{...}]
payload = {
"blocks": json.dumps(blocks)
}
You will then send this payload.
in the api, the "blocks" parameter need to be string type. Did you convert it to string or you use it as a JSON ?
https://api.slack.com/methods/chat.postMessage
In the Block Kit Builder, the data is a JSON with a blocks key.
In the Slack API, the blocks param is only the list of JSON objects.
blocks = [
{
"text": {
"text": "Its the list of your blocks",
"type": "mrkdwn"
},
"type": "section"
}
]
text = 'Alternative data in text'
client.chat_postMessage(channel=channel_id, blocks=blocks, text=text)
Another cause of this problem seems to be too many blocks being returned. I can't find any documentation about this whatsoever, but personal experience seems to indicate about 20 blocks is the maximum.
An alternative is to return fewer blocks, with paging actions -- paging works well with the "replace" message so that the content being paged through does not result in many separate messages.
It appears that not all valid elements in block kit tool can be posted as a message, despite the fact that message preview works fine in the Block Tool.
In my case, the code failed when I included an input block and passed when i removed it. The input block was generated by the Block Kit tool.
{
"type": "input",
"element": {
"type": "plain_text_input",
"action_id": "plain_text_input-action"
},
"label": {
"type": "plain_text",
"text": "Feedback",
"emoji": true
}
}
The error was
{'ok': False, 'error': 'invalid_blocks'}
Also, although the documentation for python says you need to urlEncode the JSON-based array, there is no example, and it is incorrect. https://api.slack.com/methods/chat.postMessage
You can see on line 29 in the SDK test code below that blocks= takes a regular list of dicts not a string.
https://github.com/slackapi/python-slack-sdk/blob/c9dc6aa0907a72c16cf36aa15e7e80031a9fdce2/integration_tests/samples/basic_usage/sending_a_message.py

Adding new Sensor to Object Model is failing

I am trying to modify the quick sample provided here.
I tried to add a few custom sensor data type but it is failing. Then I tried a few data types mentioned in the documentation which also failed.
I am getting below error
Creating Sensor: {
"DataType": "Noise",
"DeviceId": "some-device-id",
"HardwareId": "SAMPLE_SENSOR_NOISE"
}
Request: POST
https://******.*******.azuresmartspaces.net/management/api/v1.0/sensors
Response Status: 404, NotFound , {"error":
{"code":"404.600.000.001","message":"There is no SensorDataType of the
given name."}}
Can we add custom sensor datatype?
If no then what are the inbuilt data types? or if yes then what went wrong here?
You need to post the DataType when creating the Sensor object. Use “None” if you want to change it later. Swagger DOCs show the “Model” you can expand and see required fields.
If the DataType is not in the api/v1/system/types you will need to enable it or create a new DataType. Create a new DataType POST to the Types with the required information. The minimum is the TypeName and SpaceID to neat the type under. My typical pattern is to create a root space and append any custom twin objects like types to this space.
I believe these are case sensitive names as well.
https://{servicename}.{region}.azuresmartspaces.net/management/swagger/ui/index#/Types
EDIT:
Check your Ontologies with:
https://{servicename}.{region}.azuresmartspaces.net/management/api/v1.0/ontologies
Select these by ID and POST to set them to true to get all available built-in types:
[
{
"id": 1,
"name": "Required",
"loaded": true
},
{
"id": 2,
"name": "Default",
"loaded": true
},
{
"id": 3,
"name": "BACnet",
"loaded": true
},
{
"id": 4,
"name": "Advanced",
"loaded": true
}
]
Then you can query all the given types:
https://{servicename}.{region}.azuresmartspaces.net/management/api/v1.0/types?includes=Description,FullPath,Ontologies,Space
You should receive something like:
[
{
"id": 1,
"category": "DeviceSubtype",
"name": "None",
"disabled": false,
"logicalOrder": 0,
"fullName": "None",
"spacePaths": [
"/system"
],
"ontologies": [
{
"id": 1,
"name": "Required",
"loaded": true
}
]
},
{
"id": 2,
"category": "DeviceType",
"name": "None",
"disabled": false,
"logicalOrder": 0,
"fullName": "None",
"spacePaths": [
"/system"
],
"ontologies": [
{
"id": 1,
"name": "Required",
"loaded": true
}
]
},
{
"id": 3,
"category": "DeviceBlobSubtype",
"name": "None",
"disabled": false,
"logicalOrder": 0,
"fullName": "None",
"spacePaths": [
"/system"
],
"ontologies": [
{
"id": 1,
"name": "Required",
"loaded": true
}
]
},
...Objects,
]

Building an OpenAPI response, including oneOf, and maybe allOf

I am trying to build up a response from a variety of schema components using OpenAPI 3. There are basically three parts to the response:
A shared component that other endpoints use (i.e. success/failure flags). - #/components/schemas/core_response_schema inside allOf.
Properties that all responses on this endpoint use (i.e., user_id) - the properties component of the below.
One of several schemas that will vary depending on the type of user. - the oneOf component.
I've determined that I have to use allOf to be able to mix properties (item 2) and the core response (item 1), though this feels wrong as there's only one item. I tried a $ref, but it didn't work.
The below successfully passes three different OpenAPI linting tools, but in the example it builds, Swagger UI does not show the item 2 things (properties), and does show all of the item 3 things (should be oneOf).
"responses": {
"200": {
"description": "Operation successfully executed.",
"content": {
"application/json": {
"schema": {
"properties": {
"user_id": {
"$ref": "#/components/schemas/user_id"
},
"results": {
"type": "array",
"items": {
"$ref": "#/components/schemas/result_user_by_id"
}
}
},
"type": "object",
"allOf": [
{
"$ref": "#/components/schemas/core_response_schema"
}
],
"oneOf": [
{
"$ref": "#/components/schemas/user_type_a"
},
{
"$ref": "#/components/schemas/user_type_b"
},
{
"$ref": "#/components/schemas/user_type_c"
}
]
}
}
}
}
},
"components": {
"schemas": {
"core_response_schema": {
"properties": {
"success": {
"description": "A flag indicating whether the request was successfully completed or not.",
"type": "boolean"
},
"num_results": {
"description": "The number of results for this request",
"type": "integer"
}
},
"type": "object"
},
"user_id": {
"description": "Unique 10 character `user_id`.",
"type": "string",
"maxLength": 10,
"minLength": 10,
"example": "a1b2c3d4e5"
},
}
}
And example payloads for two users. Type A and B (it's a contrived example).
User Type A:
{
"success": true,
"num_results": 1,
"user_id": "c1b00cb714",
"results": [{
"user_type": "a",
"group_id": "e7a99e3769",
"name": null,
"title": null,
... (and so on until we get to the stuff that's unique to this type of user) ...
"favourite_artworks": [
"sunflowers",
"landscapes"
],
"artwork_urls": [
"http://sunflowers.example"
]
}
]
}
User Type B:
{
"success": true,
"num_results": 1,
"user_id": "c1b00cb715",
"results": [{
"user_type": "B",
"group_id": "e7a99e3769",
"name": null,
"title": null,
... (and so on until we get to the stuff that's unique to this type of user) ...
"supported_charities": [
"UN Foundations"
],
"charity_urls": [
"http://www.un.int"
],
}
]
}
What's the correct way to merge together different schemas and properties in OpenAPI? Is this right and Swagger UI just can't handle it?
And how do you mix a schema with properties without having to use allOf?
This suggests it's possible: Swagger Schema: oneOf, anyOf, allOf valid at the same time?
After further investigation, I've determined this is a bug in swagger-ui - https://github.com/swagger-api/swagger-ui/issues/3803 - they simply don't support oneOf (or anyOf) currently.
As far as at least three different linting tools are concerned, a mixture of anyOf, oneOf, and allOf can be used together in the same schema.
Redoc appears to have similar problems - https://github.com/Rebilly/ReDoc/issues/641

Jenkins Bitbucket Plugin - Cannot parse POST data

Sending a POST request to /jenkins/bitbucket-hook causes a 500 error:
javax.servlet.ServletException: net.sf.json.JSONException: A JSONObject text must begin with '{' at character 0 of
Regardless of the content type, or body data.
The body data being sent is that outlined by Bitbucket:
{
"canon_url": "https://bitbucket.org",
"commits": [
{
"author": "marcus",
"branch": "master",
"files": [
{
"file": "somefile.py",
"type": "modified"
}
],
"message": "Added some more things to somefile.py\n",
"node": "620ade18607a",
"parents": [
"702c70160afc"
],
"raw_author": "Marcus Bertrand <marcus#somedomain.com>",
"raw_node": "620ade18607ac42d872b568bb92acaa9a28620e9",
"revision": null,
"size": -1,
"timestamp": "2012-05-30 05:58:56",
"utctimestamp": "2012-05-30 03:58:56+00:00"
}
],
"repository": {
"absolute_url": "/marcus/project-x/",
"fork": false,
"is_private": true,
"name": "Project X",
"owner": "marcus",
"scm": "git",
"slug": "project-x",
"website": "https://atlassian.com/"
},
"user": "marcus"
}
Jenkins is the most up to date version, along with the Bitbucket plugin.
Update: I have used the data directly taken from BitBucket.
http://www.posttestserver.com/data/2015/05/20/sb/02.50.32555038623
I think I have answered my own question.
For me to get rid of that error I just had to add a trailing slash to the url... Something so simple worked for me. Might be worth others trying it too.

Resources