Deploy on heroku with Gitlab CI suddenly JSON::ParserError - ruby

My deploy process of an app to heroku is suddenly not working today and I can't find anything for this.
I have an error but I can't find any way to debug it..
Here is what I have :
$ dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_API_KEY --skip_cleanup
Installing deploy dependencies
Successfully installed rendezvous-0.1.3
Successfully installed netrc-0.11.0
Successfully installed dpl-heroku-1.10.16
3 gems installed
authentication succeeded // Some tries it is displayed some other it's not
checking for app myHerokuApp // Some tries it is displayed some other it's not
/usr/local/lib/ruby/3.1.0/json/common.rb:216:in `parse': 859: unexpected token at '<!DOCTYPE html> (JSON::ParserError)
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>Application Error</title>
<style media="screen">
html,body,iframe {
margin: 0;
padding: 0;
}
html,body {
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe src="//www.herokucdn.com/error-pages/application-error.html"></iframe>
</body>
</html>'
from /usr/local/lib/ruby/3.1.0/json/common.rb:216:in `parse'
from /usr/local/bundle/gems/dpl-heroku-1.10.16/lib/dpl/provider/heroku/generic.rb:55:in `handle_error_response'
from /usr/local/bundle/gems/dpl-heroku-1.10.16/lib/dpl/provider/heroku/generic.rb:66:in `check_app'
from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/provider.rb:188:in `block in deploy'
from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/cli.rb:41:in `fold'
from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/provider.rb:186:in `deploy'
from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/cli.rb:32:in `run'
from /usr/local/bundle/gems/dpl-1.10.16/lib/dpl/cli.rb:7:in `run'
from /usr/local/bundle/gems/dpl-1.10.16/bin/dpl:5:in `<top (required)>'
from /usr/local/bundle/bin/dpl:25:in `load'
from /usr/local/bundle/bin/dpl:25:in `<main>'
The fact is that my CI was working yesterday. If I run again an old pipeline, it will not crash. I checked :
All dependencies are still the same
ruby version is the same
dpl version is the same
my heroku app name is correct

Related

SonarQube quality gate status fetching issue

I am trying to get the status of SonarQube quality gate status using below query
curl.exe -u "78c2b8628934a6cdc8ae80f5acadaaaafdfsa96" : "https://sonarurl/api/qualitygates/project_status?projectKey=MarUiSonarQube3"
then system prompted for password, after that I got below error:
Did I miss something?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>IIS Windows</title>
<style type="text/css">
<!--
body {
color:#000000;
background-color:#0072C6;
margin:0;
}
#container {
margin-left:auto;
margin-right:auto;
text-align:center;
}
a img {
border:none;
}
-->
</style>
</head>
<body>
<div id="container">
<img src="iisstart.png" alt="IIS" width="960" height="600" />
</div>
</body>
</html>
The url you specified is the following:
curl.exe -u "78c2b8628934a6cdc8ae80f5acadaaaafdfsa96" : "https://sonarurl/api/qualitygates/project_status?projectKey=MarUiSonarQube3"
The way you've specified the token value looks slightly off. Try changing it to the following (moving the colon to right after the token):
curl.exe -u "78c2b8628934a6cdc8ae80f5acadaaaafdfsa96:" "https://sonarurl/api/qualitygates/project_status?projectKey=MarUiSonarQube3"

Local fonts not loaded correctly?

I am using Browsershot, which is based on Puppeteer to create PDF from HTML. The HTML-source is rendered Laravel-Blade.
This is my blade-template that is being rendered:
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width,initial-scale=1.0" name="viewport">
<!-- Styles -->
<link href="{{ asset(mix('/css/app.css')) }}" rel="stylesheet">
<body>
<div class="relative h-screen">
#include('pdf.partials.header')
<div class="absolute inset-x-0 bottom-0">
#include('pdf.partials.footer')
</div>
</div>
</body>
</html>
app.css contains #font-faces like:
/* lato-100 - latin */
#font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 100;
src: local('Lato Hairline'), local('Lato-Hairline'),
url('../fonts/lato-v16-latin-100.woff2') format('woff2'), /* Super Modern Browsers */ url('../fonts/lato-v16-latin-100.woff') format('woff'), /* Modern Browsers */ url('../fonts/lato-v16-latin-100.ttf') format('truetype'), /* Safari, Android, iOS */ url('../fonts/lato-v16-latin-100.svg#Lato') format('svg'); /* Legacy iOS */
font-display: swap;
}
/* lato-100italic - latin */
#font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 100;
src: local('Lato Hairline Italic'), local('Lato-HairlineItalic'),
url('../fonts/lato-v16-latin-100italic.woff2') format('woff2'), /* Super Modern Browsers */ url('../fonts/lato-v16-latin-100italic.woff') format('woff'), /* Modern Browsers */ url('../fonts/lato-v16-latin-100italic.ttf') format('truetype'), /* Safari, Android, iOS */ url('../fonts/lato-v16-latin-100italic.svg#Lato') format('svg'); /* Legacy iOS */
font-display: swap;
}
Now if I try to create a pdf, those fonts are not loaded correctly.
If I trace that down using:
$view = view('pdf', compact('data'));
$body_html = $view->render();
$requests = \Spatie\Browsershot\Browsershot::html($body_html)->format('A4')
->margins(8, 22, 8, 22)->showBackground()->addChromiumArguments([
'font-render-hinting' => 'none',
])->waitUntilNetworkIdle()->ignoreHttpsErrors()
->triggeredRequests();
dump($requests);
I see those requests:
4 => array:1 [
"url" => "http://example.test/fonts/lato-v16-latin-300.woff2?98d8cf792834c0bef59c2be99dc3533d"
]
I am able to open this path using my browser and the virtual machine Laravel lives in, is able to do so, too:
root#example:~# http://example.test/fonts/ibm-plex-mono-v5-latin-200.woff2?4b65d6136cfc2097c4a2103960f00a2c
Resolving example.test (example.test)... 127.0.0.1, 127.0.1.1
Connecting to example.test (example.test)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 200 OK
But the fonts are still not applied.
Now if I simply use Google fonts like this
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width,initial-scale=1.0" name="viewport">
<!-- Styles -->
<link href="{{ asset(mix('/css/app.css')) }}" rel="stylesheet">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght#0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&family=Lato:ital,wght#0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap" rel="stylesheet"></head>
<body>
<div class="relative h-screen">
#include('pdf.partials.header')
<div class="absolute inset-x-0 bottom-0">
#include('pdf.partials.footer')
</div>
</div>
</body>
</html>
it works just fine.
So what did I do wrong?
We had success using this tool to get the base64 version of the google font we were trying to use locally. Embedding the font as base64 right in the CSS allowed us to get around this issue.

The attribute 'amp4ads' may not appear in tag 'html'

I was developing AMP Ad as advertiser. I tested the sample amp4ads provided by ampByExample.com (official starter codes)
https://ampbyexample.com/amp-ads/introduction/hello_world/
I found amp4ads is not VALIDATED by official validator (link below)
https://validator.ampproject.org/
here is the sample snippet you can test it on validator
<html ⚡4ads>
<head>
<meta charset="utf-8">
<title> Hello World</title>
<script async src="https://cdn.ampproject.org/amp4ads-v0.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp4ads-boilerplate>body{visibility:hidden}</style>
<style amp-custom>
h1 {
color: red;
}
</style>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
It throws a lot of errors. Can anyone help me fix this issue, I couldn't find anything related.
Thanks
Unfortunately, validator.ampproject.org does not support AMP Ads. If you open the page in the AMP Playground you'll see that it's valid: https://ampbyexample.com/playground/#url=https%3A%2F%2Fampbyexample.com%2Famp-ads%2Fintroduction%2Fhello_world%2Fsource%2F&runtime=amp4ads.

Deploy customize webchat bot framework

I clone this repo https://github.com/Microsoft/BotFramework-WebChat and I managed to edit css in local.
I would like to know what I need to deploy to use webchat online ?
Thanks you for you help
I clone this repo https://github.com/Microsoft/BotFramework-WebChat and I managed to edit css in local. I would like to know what I need to deploy to use webchat online?
After you customize&build your own web chat, to embed web chat in your website, you should include your built botchat.css and botchat.js file in your project and reference botchat.css and botchat.js in your web page.
I want to add a widget like this to open my chatbot, what I need to do?
It seems that you’d like to display the chat icon in your web page to allow user dynamically open/collapse your web chat, to achieve the requirement, you need not to modify the botchat.js file, the following code sample work for me , you can refer to it.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="BotChat/botchat.css" rel="stylesheet" />
<script src="BotChat/botchat.js"></script>
<style>
#mychat {
margin: 10px;
position: fixed;
bottom: 30px;
right: 10px;
z-index: 1000000;
}
</style>
</head>
<body>
<div id="container">
<h1>Hello World</h1>
<!--other page contents-->
<img id="mychat" src="https://i.stack.imgur.com/RD7i4.png" style="float:right" />
</div>
</body>
</html>
<script>
(function () {
var div = document.createElement("div");
document.getElementsByTagName('body')[0].appendChild(div);
div.outerHTML = "<div id='botDiv' style='width: 400px; height: 0px; margin:10px; position: fixed; bottom: 0; right:0; z-index: 1000;><div id='botTitleBar' style='height: 40px; width: 400px; position:fixed; cursor: pointer;'></div></div>";
BotChat.App({
directLine: { secret: '{directline_secret}' },
user: { id: 'You' },
bot: { id: '{your_botid}' }
}, document.getElementById("botDiv"));
document.getElementsByClassName("wc-header")[0].setAttribute("id", "chatbotheader");
document.querySelector('body').addEventListener('click', function (e) {
e.target.matches = e.target.matches || e.target.msMatchesSelector;
if (e.target.matches('#chatbotheader')) {
var botDiv = document.querySelector('#botDiv');
botDiv.style.height = "0px";
document.getElementById("mychat").style.display = "block";
};
});
document.getElementById("mychat").addEventListener("click", function (e) {
document.getElementById("botDiv").style.height = '500px';
e.target.style.display = "none";
})
}());
</script>
Test result:
If I want to add a widget like this
to open my chatbot, what I need to do ? Is it enough to modify the botchat.js file ?
How to have an application like in this post?
if you want to use iframe then you can't customize the design . for customize design you need to use Direct line by you can change design as well as make bot fully responsive.
Here is the code i am using working fine for me:
<!DOCTYPE html>
<html class="no-js lang-en" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<!-- For Bot Frame -->
<link href="../assets/SCSS/botchat-fullwindow.css" type="text/css" rel="stylesheet" />
<link href="../assets/SCSS/botchat.css" type="text/css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body class="personal-body">
<!-- For Bot Code -->
<div id="BotChatElement">
</div>
<img src="../assets/images/chat-2-icon.png" onclick="openchatbot()" class="open-bot" id="button_chat" />
<script src="../assets/JS/botchat.js"></script>
<script>
var model = {
"userId": "demo1234",
"userName": "You",
"botId": "Chatbot Main Tree",
"botIconUrl": "",
"botName": "Chatbot Main Tree",
"secret": "",
"iconUrl": "",
"directLineUrl": "https://webchat.botframework.com/v3/directline",
"webSocketEnabled": "false"
};[enter image description here][1]
BotChat.App({
directLine: {
secret: model.secret,
token: model.token,
domain: model.directLineUrl,
webSocket: false,
sendTyping: true
},
user: { id: model.userId, name: model.userName },
bot: { id: model.botId, name: model.botName },
sendTyping: true,
resize: 'window'
},
document.getElementById("BotChatElement"));
function openchatbot() {
$(".wc-chatview-panel *").removeClass("maximizebot");
$(".wc-chatview-panel").css({ 'bottom': '0', 'display': 'block' });
}
$(".minimize-icon").on('click',
function () {
$(".wc-chatview-panel").removeClass("minimize-icon");
$(".wc-chatview-panel ").toggleClass("minimizebot");
$(".minimize-icon ").toggleClass("maximizebot");
});
$(".close-icon").on('click',
function () {
$(".wc-chatview-panel ").removeClass("minimizebot");
$(".wc-chatview-panel ").removeClass("maximizebot");
$(".wc-chatview-panel").css({ 'bottom': '-500px', 'display': 'none' });
});
</script>
</body>
</html>
To deploy your bot follow those steps:
Create an Azure account.
You can create free trial Azure subscription from here.
Deploying the a MS Bot framework code to Azure:
You can see this video deploying a MS Bot framework code to Azure
WebChat channel using Visual Studio.
Also you can check this tutorial. (However, this tutorial use old version of Azure portal).
After connecting the bot with WebChat channel, you can use the Embed code in your HTML code.

Japanese characters not supported by rmagick

I'm tring to build a voucher from template by rmagick, (using utf8 encoding) Below is just a small code snippet
text.annotate(template, 0, 0, 23, 155, offer_label) {
self.pointsize = 16
self.font_weight = BoldWeight
}
When i provide offer_label as 安価な価格でホテルを予約 (japanese)
so in the voucher that is created, the offer_label is dispayed as ????????????.
The offer_label is stored correctly in the database
Template code snippet:
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><%= #from_name %></title>
<style type="text/css">
a:hover { color: #09F !important; text-decoration: underline !important; }
</style>
</head>
I looked around the suggested questions but no luck.Looking forward for suggestions.
UPDATE:
The label_name is displayed correctly in the browser web pages, this issue only comes in the voucher which is created using rmagick
1) you should install Japanese font(s) to your runtime environment(s).
you can check this via Magick.fonts whether you've installed it or not.
2) specify font related attributes.
use Draw#annotate and specify font name/font_family name that you'd like to use.
Hope this helps.

Resources