amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Development mode: MANDATORY_TAG_MISSING amphtml engine v1.js script

Open gustavopaes opened this issue 11 years ago • 39 comments

What means this development mode message? MANDATORY_TAG_MISSING amphtml engine v1.js script

Tks

gustavopaes avatar Sep 16 '15 13:09 gustavopaes

Could you paste the HTML of the page you are validating?

cramforce avatar Sep 16 '15 13:09 cramforce

<!doctype html>
<html AMP>
<head>
  <meta charset="utf-8">
  <title>UOL - O melhor conteúdo</title>
  <link rel="canonical" href="http://noticias.dev.uol.com.br/politica/ultimas-noticias/2015/09/11/comissao-da-verdade-aponta-oficiais-do-exercito-como-autores-de-atentado-a-oab.htm" >
  <link rel="shortcut icon" href="http://h.imguol.com/favicon.ico" type="image/x-icon"/>
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui">
  <script custom-element="amp-iframe" src="https://www.gstatic.com/amphtml/v0/amp-iframe-0.1.js" async></script>
  <script custom-element="amp-lightbox" src="https://www.gstatic.com/amphtml/v0/amp-lightbox-0.1.js" async></script>
  <script src="https://www.gstatic.com/amphtml/v0.js" development></script>
  <!--<script src="http://localhost:8000/dist/amp.js" development></script>-->
  <style>
  body, div, p, h1, h2, h3, article, header, section, ul, li, ol {
  padding: 0;
  margin: 0;
}
ul, li, ol {
  list-style: none;
}
a {
  text-decoration: none;
  color: inherit;
}
body {
  font-family: arial;
  /* padding para permitir leitura completa da página devido banner fixed */
  padding-bottom: 50px;
}
header {
  background-color: #297ACC;
  line-height: 40px;
  height: 40px;
}
/** embed foto lightbox */
.embed-foto-lightbox {
  background: #222;
}
.embed-foto-lightbox-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
}
.embed-foto-lightbox amp-img {
  width: 100%;
}
/** /embed foto */
/** imagem representativa */
.imagem-representativa .foto-legenda {
  margin-top: 5px;
}
/** legenda de qualquer foto */
.foto-legenda {
  display: block;
  font-size: 14px;
  font-weight: bold;
  line-height: 18px;
  color: #333;
  padding: 0 5px;
}
.foto-credito {
  font-size: 11px;
  line-height: 16px;
  color: #333;
  display: block;
  text-align: right;
}
/* álbum de fotos */
.album .foto-legenda {
  padding: 5px;
  background-color: #ddd;
  font-weight: normal;
  font-size: 16px;
  line-height: 22px;
}
.album .foto-legenda a {
  font-weight: bold;
}
.album section {
  margin-bottom: 20px;
}
/** separação dop rimeiro embed da matéria */
.imagem-representativa,
article .video-embed {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #ddd;
}
.sprite {
  display: inline-block;
  text-indent: -999em;
  overflow: hidden;
  background-repeat: no-repeat;
  text-align: left;
  direction: ltr;
}
.sprite-logo {
  float: left;
  background-image: url("http://imguol.com/c/_layout/v1/mobile/uol/smart/sprites/data-uri/logo-uol.png");
  width: 88px;
  height: 40px;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.sprite-estacao {
  float: left;
  margin-top: 7px;
  margin-left: 5px;
  background-size: cover;
}
article {
  padding: 10px;
}
article h1 {
  font-size: 24px;
  padding: 5px 0 12px;
  color: #000;
  line-height: 30px;
  letter-spacing: -0.05em;
}
article .creditos {
  display: block;
  margin: 12px 0 24px 0;
  font-size: 12px;
}
article .creditos time {
  color: #666;
}
article .creditos .agencia {
  display: block;
  margin-bottom: 30px;
}
.news,
article p {
  font-size: 17px;
  color: #333;
  line-height: 25px;
  margin-bottom: 10px;
}
figure {
  display: block;
  margin: 20px 0;
  text-align: center;
}
figure .author {
  display: block;
  line-height: 13px;
  color: #666;
  font-size: 11px;
  text-align: right;
}
figure .description {
  font-size: 14px;
  font-weight: bold;
  display: block;
  text-align: left;
  line-height: 18px;
  margin-top: 5px;
  color: #333;
}
.s300x200 .author {
  width: 300px;
  margin-left: auto;
  margin-right: auto;
}
/* banners */
aside {
  text-align: center;
  padding: 10px;
  margin: 20px 0;
}
aside.fixed {
  padding: 0;
  margin: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50px;
  background-color: #fff;
}
/* rodapé */
footer {
  color: #fff;
}
footer p {
  line-height: 30px;
  font-size: 12px;
  text-align: center;
}
/*
.nav-footer {
  margin-top: 35px;
  margin-bottom: 15px;  
}
.nav-footer h2 {
  color: #297ACC;
  font-size: 14px;
  line-height: 35px;
  border-bottom: 1px solid #ddd;
  font-weight: bold;
  padding-left: 10px;
}
.nav-footer li {
  border-bottom: 1px solid #ddd;
  padding-left: 10px;
}
.nav-footer li a {
  font-size: 14px;
  line-height: 40px;
  display: block;
}
*/
        header {
    background-color: #297acc;
  }
  .sprite-estacao {
    background-image: url('http://mobile.imguol.com/projeto-grafico/v1/mobile/uol/smart/sprites/noticias/noticias/titulos.png');
    width: 96px;
    height: 26px;
  }
                  .bg1 { background-color: #1473CC; }
                .bg2 { background-color: #002c68; }
                .bg3 { background-color: #f3f2f1; }
                .bg4 { background-color: #2670bc; }
                .bg5 { background-color: #297acc; }
                .bg6 { background-color: #398fe5; }
                .bg7 { background-color: #f3f2f1; }
                .bg8 { background-color: #398fe5; }
                .bg9 { background-color: #297acc; }
                .bg10 { background-color: #363636; }
                .bg11 { background-color: #398fe5; }
                .bg12 { background-color: #1b4f85; }
                .bg13 { background-color: #297acc; }
                .bg14 { background-color: #297acc; }
  </style>
</head>
<body>
  <amp-pixel width=1 height=1 src="//metrics.uol.com.br/b/ss/uolreport133dev/1/$RANDOM?&amp;gn=$CANONICAL_URL&amp;ch=home&amp;c1=home&amp;v1=home&amp;c4=home&amp;v4=home&amp;c5=home&amp;v5=home&amp;c7=10:30AM&amp;v7=10:30AM&amp;c8=Wednesday&amp;v8=Wednesday&amp;c9=Weekday&amp;v9=Weekday&amp;c50=$CANONICAL_URL&amp;ev=event1&amp;cdp=3&amp;ce=ISO-8859-1"></amp-pixel>
  <header class="bg5">
    <a class="sprite sprite-logo" href="http://www.uol.com.br/amp">UOL</a>
    <a class="sprite sprite-estacao" href="http://www.uol.com.br/amp">Notícias</a>
  </header>
<article>
  <h1>Comissão da Verdade aponta oficiais do Exército como autores de atentado à OAB</h1>
  <span class="creditos">
                    <strong>Gustavo Maia</strong><br/>
                    <strong>Do UOL, no Rio</strong>
        <time datetime="2015-09-11T11:25">
      11/09/2015 - 11h25
                    <span class="separador"> > </span>
        Atualizada 11/09/2015 - 12h22
          </time>
  </span>
  <div class="news">
                   <div class="imagem-representativa">
          <span class="foto-credito">Lewy Moraes/Folhapress</span>
          <amp-img id="img-lightbox0" src="http://imguol.com/c/noticias/85/2015/09/11/sede-da-oab-ordem-dos-advogados-do-brasil-no-rio-de-janeiro-apos-a-explosao-da-carta-bomba-que-causou-a-morte-da-secretaria-lyda-monteiro-..." width=300 height=200 layout="responsive" on="tap:lightbox0"></amp-img>
          <strong class="foto-legenda">Sede da OAB no Rio ap&#243;s a explos&#227;o da carta-bomba que causou a morte da secret&#225;ria Lyda Monteiro da Silva</strong>
          <amp-lightbox id="lightbox0" class="embed-foto-lightbox" layout="nodisplay" from="img-lightbox0">
            <div class="embed-foto-lightbox-content">
              <amp-img src="http://imguol.com/c/noticias/85/2015/09/11/sede-da-oab-ordem-dos-advogados-do-brasil-no-rio-de-janeiro-apos-a-explosao-da-carta-bomba-que-causou-a-morte-da-secretaria-lyda-monteiro-da-silva-..." width=300 height=200 layout="responsive"></amp-img>
            </div>
          </amp-lightbox>
        </div>
    <p>Lorem ipsum....</p>
          </div>
  <aside>
    <amp-ad width=300 height=250
      type="doubleclick"
      data-slot="/8804/uol_mobile/home">
    </amp-ad>
  </aside>
</article>
  <amp-pixel width=1 height=1 src="//h.imguol.com/x.gif"></amp-pixel>
  <footer class="bg5">
    <p>&copy; UOL 1996-2015</p>
  </footer>
  <aside class="fixed">
    <amp-ad width=320 height=50
      type="doubleclick"
      data-slot="/8804/uol_mobile/home">
    </amp-ad>
  </aside>
</body>
</html>

gustavopaes avatar Sep 16 '15 13:09 gustavopaes

@Gregable @powdercloud Surprised this does not validate. Seems to match our regex.

cramforce avatar Sep 16 '15 13:09 cramforce

We do get this error too in all our pages

teleservizi avatar Sep 16 '15 15:09 teleservizi

We do as well

NataliaLKB avatar Sep 16 '15 15:09 NataliaLKB

The validator I pushed yesterday has a better error message for this. I just tried it and in fact, you do get the newer error message. If you force reload to get a new copy of the amp code, you will be seeing:

http://localhost:8000/test.html:11:2 DISALLOWED_ATTR development http://localhost:8000/test.html:252:55 MANDATORY_TAG_MISSING amphtml engine v1.js script

The issue is that the development attribute doesn't currently validate, though it does trigger validation. Since that script tag doesn't validate, the validator also complains that the required amphtml script is missing as well.

This is something I was aware of that we'd want to decide what to do with, but for now I left it as non-validating. We probably want the javascript validator to pass, but to still console.log some type of warning that the development tag is enabled, since that will cause a performance hit when rendering the page.

We also probably will not want to index pages with the development tag, so technically this still doesn't validate. Alternatively, I could leave this as is. I think what's going on at least clearer with the new error message.

Gregable avatar Sep 16 '15 17:09 Gregable

@Gregable Yeah, lets do the following: The validator in JS allows the development tag and the runtime informs the user that development mode is on and that it should not be on in prod.

We'd probably remove the development attribute in our serving system, so we don't need to necessarily fail validation. Would be good if we had a warning feature.

cramforce avatar Sep 16 '15 17:09 cramforce

@cramforce That sounds great and solves the problem holding me back from implementing a warning which is that the validator API had no mechanism to return warnings. I'll package that change up in the next CL.

Gregable avatar Sep 16 '15 17:09 Gregable

Might be also good for us to add "devmode" somewhere on the page's DOM. On Sep 16, 2015 10:07 AM, "Malte Ubl" [email protected] wrote:

@Gregable https://github.com/Gregable Yeah, lets do the following: The validator in JS allows the development tag and the runtime informs the user that development mode is on and that it should not be on in prod.

We'd probably remove the development attribute in our serving system, so we don't need to necessarily fail validation. Would be good if we had a warning feature.

— Reply to this email directly or view it on GitHub https://github.com/ampproject/amphtml/issues/174#issuecomment-140806061.

dvoytenko avatar Sep 16 '15 17:09 dvoytenko

@powdercloud suggested offline that we probably should implement this in the validator as a warning rather than in the runtime, at least in the medium term.

The validator code can also be run as a nodejs CLI binary which may eventually be used inside build systems or other development toolchains. Having the warning be present there would be a useful feature and in general it would be better to implement in one place rather than multiple.

Additionally, removing the attribute in the serving system might encourage publishing with the attribute left in place. This wouldn't be a good thing to encourage since we want these to be servable from the origin.

Gregable avatar Sep 16 '15 19:09 Gregable

SGTM

cramforce avatar Sep 16 '15 19:09 cramforce

Here's an attempt at this - what's below is hypothetical / not implemented.

There are two orthogonal things:

  • The error code. It indicates what's wrong, e.g., "tag missing", "attribute value invalid", "developer mode on", "deprecated attribute used", etc.
  • The warning level, explaining whether something needs to be done. Right now we have only error, indicating "you must fix this right now".

I think we need to evolve the warning level. I see four states.

  • NONE: It's cool - as in, we wouldn't generate any error anyways.
  • DEV_WARNING: It's cool in development but not in prod. E.g., "development mode on" is a warning when developer mode is turned on, but an error in production. Like, an indexing system should drop a document with this type of warning, because it would encourage / hide a rather serious issue with the original page, because users which directly visit it with an HTML browser now run a Javascript validator.
  • PROD_WARNING: It's cool in prod but not in development. An example for this would be "deprecated attribute used". A developer who gets this message should certainly fix their document, but in production (e.g., an indexing system) we would still support it.
  • ERROR: It's not cool, period.

Any "Error" event object would carry with it any of those four states. It's less complicated in practice, because NONE wouldn't be used, and ERROR is the default. So basically in practice it boils down to tagging some events as DEV_WARNING / PROD_WARNING. A usage of the validator can then select between "developer mode" and "production mode", and the only difference between the two is the final status: in developer mode (in practice what's selected when you turn on development via the amp.js runtime), any PROD_WARNING / ERROR will lead to overall failure. In production mode (in practice what runs in a typical indexing system), any DEV_WARNING / ERROR will lead to overall failure. At the risk of being overly verbose with this comment, here are made up examples with these new error states:

Via amp.js ("tells that developer mode is on but allows it"): PASS foo.html:13:5 DEV_WARNING: DEVELOPER_MODE script.development

Via amp.js ("makes people move away from deprecated stuff"): FAIL foo.html:2:3 PROD_WARNING: DEPRECATED_ATTR doctype.amphtml

In an indexing system ("doesn't support developer mode on tag"): FAIL foo.html:13:5 DEV_WARNING: DEVELOPER_MODE script.development

In an indexing system ("still supports some deprecated attribute"): PASS foo.html:2:3 PROD_WARNING: DEPRECATED_ATTR doctype.amphtml

In case it's not clear - the deprecation stuff isn't implemented yet, but the need is already there: I'd like to deprecate the doctype amp attribute, but right now it emits nothing when it's used.

powdercloud avatar Sep 16 '15 20:09 powdercloud

I believe this is fixed?

cramforce avatar Sep 17 '15 18:09 cramforce

The error is no longer being reported, but that's a bit of a short term hack. Let's leave this open to improve on this output in the near future. It can be removed from blocking anything though.

Gregable avatar Sep 17 '15 18:09 Gregable

The code is now doing exactly what I described earlier. Our Javascript validator is always in development mode, basically - so having the development attribute there is a warning to tell the user that they'll have to remove it. The C++ validator is by default in production mode, so having the development attribute is an error. I'll close this.

powdercloud avatar Sep 30 '15 08:09 powdercloud

Actually looks like I can't close it but I bet @cramforce can?

powdercloud avatar Sep 30 '15 08:09 powdercloud

Could you please clarify this for me one more time? I just went to my local and added development tag and got this in the console.error:

http://localhost:8000/test/manual/amp-image-lightbox.amp.html:10:2 DEV_MODE_ENABLED development - please remove for prod (see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#amp-runtime)

I looked into (obfuscated) valdiator.js and from what I can see it indeed logs via "console.error".

Am I missing something?

dvoytenko avatar Sep 30 '15 19:09 dvoytenko

Ah I think all the output from the validator may be going to console.error, but you're expecting console.warn for warnings? So there maybe something to fix after all. :-) What I was working on was what makes it fail / pass. I suspect for your example, it still says that the status is pass. But maybe not enough as a hint.

powdercloud avatar Oct 01 '15 01:10 powdercloud

Ideally any warning would go into console.warn on JS side. I think right now we only have "development" attr as a warning. But we are expecting to add more warnings.

On Wed, Sep 30, 2015 at 6:58 PM, Johannes Henkel [email protected] wrote:

Ah I think all the output from the validator may be going to console.error, but you're expecting console.warn for warnings? So there maybe something to fix after all. :-) What I was working on was what makes it fail / pass. I suspect for your example, it still says that the status is pass. But maybe not enough as a hint.

— Reply to this email directly or view it on GitHub https://github.com/ampproject/amphtml/issues/174#issuecomment-144593580.

dvoytenko avatar Oct 01 '15 02:10 dvoytenko

I agree.

powdercloud avatar Oct 01 '15 09:10 powdercloud