Firebase redirect example from the docs throws error: Unexpected token. Why? - firebase-hosting

I wanted to add redirects to my firebase project, so I pasted the example from the offical docs as a test:
"hosting": {
// ...
"redirects": [ {
"regex": "/blog/(?P<post>.+)", // if you're familiar with PCRE, be aware that RE2 requires named capture groups to begin with ?P
"destination": "https://blog.myapp.com/:post", // includes the entire URL segment identified and captured by the `regex` value
"type": 301
}, {
"regex": "/users/(\d+)/profile", // uses the \d directive to only match numerical path segments
"destination": "/users/:1/newProfile", // the first capture group to be seen in the `regex` value is named 1, and so on
"type": 301
} ]
}
When I tried to deploy I got the error:
Error: There was an error loading firebase.json:
Unexpected token 'd' at 28:26
"regex": "/users/(\d+)/profile",
^
How come the official example gets a syntax error? What is the problem?

You need to escape the backslash \\d.

Related

Content-Language metadata field in GCS object not allowing ISO-639-2 from API

While trying to update the Content-Language metadata field of an object to ISO-639-2 field from the UI works fine, when trying to do the same from http API, it fails with an invalid argument error. The official documentation page states that ISO-639-1 codes are supported (although the link goes to 639-2).
Any ideas on how to update the Content-Language via http/json for objects in ISO-639-2 ? Or it's possible the UI treats it differently?
Response from GetObject for an object with ISO-639-2 updated via ui
{
"kind": "storage#object",
"id": "XXXXXXXXX/textfile.txt/XXXXXXX",
"selfLink": ...,
"mediaLink": ...,
"name": "textfile.txt",
"bucket": "XXXXXX",
"generation": "XXXXXX",
"metageneration": "2",
"contentType": "text/plain; charset=utf-8",
"storageClass": "STANDARD",
"size": "29",
"md5Hash": "f510qpm7Jh30uKbBcN4e0A==",
**"contentLanguage": "ach",**
"crc32c": "4fnpOw==",
"etag": "COet043XpPcCEAI=",
"temporaryHold": false,
"eventBasedHold": false,
"timeCreated": "2022-04-21T07:56:14.769Z",
"updated": "2022-04-21T07:57:14.321Z",
"timeStorageClassUpdated": "2022-04-21T07:56:14.769Z",
"metadata": {
"gcsfuse_mtime": "2022-04-21T07:56:13.375009661Z"
}
}
Error when trying to set the same value as received in the above call via json
{
"error": {
"code": 400,
"message": "Invalid argument.",
"errors": [
{
"message": "Invalid argument.",
"domain": "global",
"reason": "invalid"
}
]
}
}
I reproduced your case, and it seems like you are right. Content-Language only allows ISO 639-1 language codes for the supported values of this metadata.
When Content-Language was set to “ach” in JSON POST API call it gave me errors “curl: (3) Failed to convert ach” to ACE; string contains a disallowed character” but when set to “en”/ “de”/ “aa” it works fine and gives a HTTP 200 response. I think the logic which works here, checks for ISO 639-1 format.
I have gone through the documentation, and it says clearly “Refer to ISO 639-1 language codes for the supported values of this metadata.” Maybe it routes to ISO 639-2 page, because it contains both ISO 639-1 and ISO 639-2 codes, out of which it mentions it only supports ISO 639-1 language codes. You can check out this documentation as well.
Raise a feature request here so that the Content-Language supports ISO 639-2 language code in API calls.

A combination of supportedLocales and fallbackLocale doesn't prevent UI5 from requesting unexisting i18n-localizations

To configure the i18n functionality in UI5, I'm using the following snippet in the sap.ui5 of manifest.json:
"models": {
"i18n": {
"preload": true,
"settings": {
"bundleName": "webapp.i18n.i18n",
"bundleUrl": "i18n/i18n.properties",
"fallbackLocale": "en",
"supportedLocales": [
"en"
]
},
"type": "sap.ui.model.resource.ResourceModel"
}
},
Thanks to supportedLocales and fallbackLocale I don't expect that UI5 will request unexisting localizations, but in fact I still observe unwanted 404-requests for i18n_en_US.properties:
GET http://localhost:3000/i18n/i18n_en_US.properties 404 (Not Found)
I assumed that the whole idea behind of supportedLocales and fallbackLocale is to reduce amount of requests of localizations, which don't exist and are not specified in supportedLocales.
My questions:
Why UI5 anyway tries to request i18n_en_US.properties although en_US doesn't appear in a list of supportedLocales?
Is it possible to get rid of extra requests for unsupported locales?
I figured out the reason for the unwanted 404-requests.
Initially, I've defined fallbackLocale and supportedLocales for the sap.ui5/models/i18n section, but there is also an i18n section in sap.app, which also requires fallbackLocale and supportedLocales configuration.
The final solution is to add the following code-snippet into sap.app section of manifest.json:
"i18n": {
"bundleName": "webapp.i18n.i18n",
"fallbackLocale": "en",
"supportedLocales": [
"en"
]
},

is there a way to put web-activity result into sql-table (sink)

Unable to get the output of a web activity into a sql-table using azure-data-factory.
This is what i have done and where im getting stuck (Step 3).
Steps:
1.Get a token from a API-call
Get the results from API Call using token from step 1
and tkae this results in a successfull query that provides me with 'JSON'
Take the result from previous activity 'JSON' and put in in a azure sql database table.
azure-datafactory - web activites
Can you not get this done using a copy activity ? You should configure the source as Web activity and sink as SQL. I was playing with this http://dummy.restapiexample.com/api/v1/employees and we needed to introduce the structure . This is what I did and it work .
"source": {
"type": "RestSource",
"httpRequestTimeout": "00:01:40",
"requestInterval": "00.00:00:00.010",
"structure": [
{
"id": "id"
},
{
"employee_salary": "employee_salary"
}
]
},
"sink": {
"type": "SqlServerSink",
"writeBatchSize": 10000
},
"enableStaging": false
},
You can read more . https://learn.microsoft.com/en-us/azure/data-factory/copy-activity-schema-and-type-mapping

Validation Error (Error Code 422) while trying to POST Hyperledger Transaction on REST API using POSTMAN

I was trying to test Transactions via Playground, Composer-Rest-server and Finally POSTMAN.
The Transactions worked perfectly on Playground (Figure 1 and 2) and also on the Composer-Rest-Server (Figure 3 and 4). But then I tried the same using POSTMAN, for which I am getting an Error ( Status Code 422 )(Figure 5).
I'm using the basic-sample-network. And the Transaction just updates the value of the asset.
Figure 1 - Executing Sample Transaction On Playground
Figure 2 - Updated Value of Asset #3952
Figure 3 - Executing the Transaction on the composer Rest Server
Figure 4 - Updated Value of Asset #3952 after the Rest Server Transaction
Figure 5 - Error While Using POSTMAN
The Error
"error": {
"statusCode": 422,
"name": "ValidationError",
"message": "The `org_example_basic_SampleTransaction` instance is not valid. Details: `asset` can't be blank (value: undefined); `newValue` can't be blank (value: undefined).",
"details": {
"context": "org_example_basic_SampleTransaction",
"codes": {
"asset": [
"presence"
],
"newValue": [
"presence"
]
},
"messages": {
"asset": [
"can't be blank"
],
"newValue": [
"can't be blank"
]
}
},
"stack": "ValidationError: The `org_example_basic_SampleTransaction` instance is not valid. Details: `asset` can't be blank (value: undefined); `newValue` can't be blank (value: undefined).\n at ...
What is the reason for this Error and How can I solve it?
You have to post data in JSON format.

Google Actions SDK Sign-In implicit flow

EDIT: On phone assistant its working now problem just exist in google action simulator
I just try to setup Google Actions SDK account Linking with implicit grant and try to test it in Simulator.
First question is this even possible in Simulator?
To Do so I added at the action console account linking with the type
implicit grant to my action.
The url I used is working.
Now I added a signup request to my action. For testing so if I write signup in simulator the server response with:
{
conversationToken: JSON.stringify(state),
expectUserResponse: true,
expectedInputs: [
{
inputPrompt: {
initialPrompts: [
{
textToSpeech: "PLACEHOLDER_FOR_SIGN_IN"
}
],
noInputPrompts: []
},
possibleIntents: [
{
"intent": "actions.intent.SIGN_IN",
"inputValueData": {}
}
],
speechBiasingHints: []
}
]
}
After this the server didn't request the sign in page route (the address is correct!). It just responds with SignIN intent ERROR :
{
"isInSandbox'": false,
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
},
"inputs": [
{
"rawInputs": [
{
"query": "i think so",
"inputType": "VOICE"
}
],
"arguments": [
{
"name": "SIGN_IN",
'extension': {
"#type": "type.googleapis.com/google.actions.v2.SignInValue",
"status": "Error"
}
}
],
"intent': "actions.intent.SIGN_IN"
}
],
"device": {
"locale": "en-US"
},
"conversation": {
"conversationId": "1494606917128",
"type": "ACTIVE",
"conversationToken": "[\"_actions_on_google_\"]"
}
}
Why? Where is the problem? Can I see a error message somewhere?
Here is what happen in the simulator between 3 and 4:
Is it same when you use the phone app? For me it opens an embedded browser with my /auth endpoint, which the simulator doesn’t do.
I am able to make it WORKING after a long time.
We have to enable the webhook first and we can see how to enable the webhook in the dialog flow fulfillment docs
If we are going to use Google Assistant, then we have to enable the Google Assistant Integration in the integrations first.
Then follow the steps mentioned below for the Account Linking in actions on google:-
Go to google cloud console -> APIsand Services -> Credentials -> OAuth 2.0 client IDs -> Web client -> Note the client ID, client secret from there
-> Download JSON - from json note down the project id, auth_uri, token_uri
-> Authorised Redirect URIs -> White list our app's URL -> in this URL fixed part is https://oauth-redirect.googleusercontent.com/r/ and append the project id in the URL
-> Save the changes
Actions on Google -> Account linking setup
1. Grant type = Authorisation code
2. Client info
1. Fill up client id,client secrtet, auth_uri, token_uri
2. Enter the auth uri as https://www.googleapis.com/auth and token_uri as https://www.googleapis.com/token
3. Save and run
4. It will show an error while running on the google assistant, but dont worry
5. Come back to the account linking section in the assistant settings and enter auth_uri as https://accounts.google.com/o/oauth2/auth
and token_uri as https://accounts.google.com/o/oauth2/token
6. Put the scopes as https://www.googleapis.com/auth/userinfo.profile and https://www.googleapis.com/auth/userinfo.email
and weare good to go.
7. Save the changes.
In the hosting server logs, we can see the access token value and through access token, we can get the details regarding the email address.
Append the access token to this link "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" and we can get the required details in the resulting json page.
accessToken = req.get("originalRequest").get("data").get("user").get("accessToken")
r = requests.get(link)
print("Email Id= " + r.json()["email"])
print("Name= " + r.json()["name"])
P.S. You can use the Grant Type as Implicit also instead of Authorisation code.