Nunjucks error reporting on imported file - nunjucks

With Nunjucks I use the throwOnUndefined option to see where I use an undefined or null value in my output.
In my code structure I have a main file, and import files containing macro's for the actual rendering of output.
I want to report errors on, but the errors are always reported on the main file. Both in my own code, and when I use for example nunjucks-cli.
An example with nunjucks-cli:
file options.json:
{
"throwOnUndefined": true,
}
file test.njk:
{% import "macro.njk" as doit %}
{{ doit.giveError("x") }}
file macro.njk, containing an error because writing value of y:
{% macro giveError(x) %}
{{ y }}
{% endmacro %}
Nunjucks commando:
nunjucks test.njk --path . --options options.json
Error output:
Template render error: (C:\Q\nunjucks-errorreporting\test.njk) [Line 1, Column 17]
Template render error: (C:\Q\nunjucks-errorreporting\test.njk) [Line 2, Column 4]
attempted to output null or undefined value
Both errors are reported on test.njk. The first error on Line 1, Column 17, but on both files there is no relevance on column 17. The second error is Line 2, Column 4, which matches with writing out {{ y }} in the macro.njk file, but is reported on test.njk.
I get the same behaviour in my custom code.
Is there a way to get correct error reporting on the correct files, because I have file importing files, importing other files...
Update:
Based on input Lesha Ogonkov I added "dev": true to the options.json.
This results in the following output:
Error: attempted to output null or undefined value
at new TemplateError (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\lib.js:89:17)
at Object.ensureDefined (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\runtime.js:242:11)
at Object.eval (eval at _compile (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:18:38)
at Object.giveError (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\runtime.js:131:17)
at Context.<anonymous> (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\runtime.js:259:23)
at Object.callWrap (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\runtime.js:273:14)
at eval (eval at _compile (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:13:88)
at C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\environment.js:613:9
at Template.root [as rootRenderFunc] (eval at _compile (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\environment.js:631:18), <anonymous>:29:1)
at Template.getExported (C:\Q\nunjucks-errorreporting\node_modules\nunjucks\src\environment.js:609:10) {
lineno: 2,
colno: 4,
firstUpdate: false,
Update: [Function: Update]
}
I still not see a relation to the file where the error is occurring.

Try to set dev flag next to throwOnUndefined. It is undocumented nunjucks feature, that prevent stacktrace collapse.

Related

dbt + clickhouse incremental materialization - error 62

i am struggling a bit with the incremental materialization via dbt-clickhouse (+ dbt 1.3). My model looks like this (i simplified as much as i could):
{{
config(
materialized='incremental',
engine='MergeTree()',
order_by=['ts'],
unique_key=['impid']
)
}}
select ts, impid from gam.data
{% if is_incremental() %}
where ts >= now() - toIntervalHour(1)
{% endif %}
the error I am receiving is this when running dbt run:
10:16:18 :HTTPDriver for http://localhost:8123 returned response code 400)
10:16:18 Code: 62. DB::Exception: Syntax error: failed at position 312 ('empty') (line 15, col 9): empty
10:16:18 as (
10:16:18
10:16:18 select ts, impid from gam.data
10:16:18
10:16:18 )
10:16:18 . Expected one of: token, Arrow, DoubleColon, MOD, DIV, NOT, BETWEEN, LIKE, ILIK
10:16:18
10:16:18 Done. PASS=6 WARN=0 ERROR=1 SKIP=0 TOTAL=7
the funny part is that the exact same model works with the basic view materialization but not with the incremental one. I tried every single combination I could come up with but so far no luck. Did you encounter something similar?
Ok, problem solved. I reached out on dbt's slack and it seems like the dbt-clickhouse adapter requires a more recent version of Clickhouse. It is a bug as the adapter should work with as versions as low as 22.7.1 but it does not. That being said, after upgrading the server, everything works fine.

Sphinx-autodoc with napoleon (Google Doc String Style): Warnings and Errors about Block quotes and indention

I am using Sphinx 4.4.0 with napoleon extension (Google Doc String). I have this two problems
ARNING: Block quote ends without a blank line; unexpected unindent.
ERROR: Unexpected indentation.
I found something about it on the internet but can not fit this two my code. My problem is I even do not understand the messages. I do not see where the problem could be.
This is the code:
def read_and_validate_csv(basename, specs_and_rules):
"""Read a CSV file with respect to specifications about format and
rules about valid values.
Hints: Do not use objects of type type (e.g. str instead of "str") when
specificing the column type.
specs_and_rules = {
'TEMPLATES': {
'T1l': ('Int16', [-9, ' '])
},
'ColumnA': 'str',
'ColumnB': ('str', 'no answer'),
'ColumnC': None,
'ColumnD': (
'Int16',
-9, {
'len': [1, 2, (4-8)],
'val': [0, 1, (3-9)]
}
}
Returns:
(pandas.DataFrame): Result.
"""
This are the original messages:
.../bandas.py:docstring of buhtzology.bandas.read_and_validate_csv:11: WARNING: Block quote ends without a blank line; unexpected unindent.
.../bandas.py:docstring of buhtzology.bandas.read_and_validate_csv:15: ERROR: Unexpected indentation.
.../bandas.py:docstring of buhtzology.bandas.read_and_validate_csv:17: ERROR: Unexpected indentation.
.../bandas.py:docstring of buhtzology.bandas.read_and_validate_csv:19: WARNING: Block quote ends without a blank line; unexpected unindent.
.../bandas.py:docstring of buhtzology.bandas.read_and_validate_csv:20: WARNING: Block quote ends without a blank line; unexpected unindent.
reStructuredText is not Markdown, and indentation alone is not enough to demarcate the code block. reStructuredText calls this a literal block. Although the use of :: is one option, you might want to explicitly specify the language (overriding the default) with the use of the code-block directive.
Also I noticed that you have invalid syntax in your code block—a missing ) and extra spaces in your indentation—which could have caused those errors.
Try this.
def read_and_validate_csv(basename, specs_and_rules):
"""Read a CSV file with respect to specifications about format and
rules about valid values.
Hints: Do not use objects of type type (e.g. str instead of "str") when
specificing the column type.
.. code-block:: python
specs_and_rules = {
'TEMPLATES': {
'T1l': ('Int16', [-9, ' '])
},
'ColumnA': 'str',
'ColumnB': ('str', 'no answer'),
'ColumnC': None,
'ColumnD': (
'Int16',
-9, {
'len': [1, 2, (4-8)],
'val': [0, 1, (3-9)]
}
)
}
Returns:
(pandas.DataFrame): Result.
"""

terraform plan is giving the error : function call (function yamldecode)

Please find the GitLab repo for the terraform scripts which we are using.
enter link description here
Run in terraform plan gives the below error in an all-in-one.YAML file for the elastic search.
Error: Error in function call
on kubernetes.tf line 49, in locals:
49: resource_list = yamldecode(file("${path. module}/all-in-one.yaml")).items
|----------------
| path.module is "."
Call to function `"yamldecode"` failed: on line 458, column 1: unexpected extra
content after value.
enter image description here
As is describe in the fine manual:
Only one YAML document is permitted. If multiple documents are present in the given string then this function will return an error.
and one can trivially reproduce your error message:
content = yamldecode("---\nhello: world\n---\ntoo: bad\n")
on main.tf line 14, in resource "local_file" "example":
14: content = yamldecode("---\nhello: world\n---\ntoo: bad\n")
Call to function "yamldecode" failed: on line 2, column 1: unexpected extra
content after value.

Jekyll error: undefined method ancestors for nil:NilClass

My post template in jekyll renders a presentation either of Google slides or of a jupyter notebook html. For this purpose, I use the markdown structure shown below:
---
layout: post
title: title
date: 2018-10-28 00:00:00 -0500
categories: category
author: author
medium: jupyter
link: [//]: # (Here I insert the presentation url)
lang: en
---
<div>
{% if page.medium == 'jupyter' %}
{% include jupyter.html link=page.link %}
{% elsif page.medium == 'gslides' %}
{% include gslides.html link=page.link %}
{% else %}
{% include nodata.html %}
{% endif %}
</div>
This generates the desired result. However, during the bundle creation, jekyll outputs this error for each post file:
Error: A Liquid tag in the excerpt of ./file.markdown couldn't be parsed.
Error: could not read file ./file.markdown: undefined method `ancestors' for nil:NilClass
I have already looked for any syntax errors along with this and other files, and all seems to be ok. Does someone has gone through a similar problem?
EDIT: I've taken the elif and the else clause of the statement, only then the problem ceases.

Jekyll: Using values from _config.yml in SCSS partial

In my Jekyll project, I have the following in my _config.yml file:
colors:
- name: red
hex: '#FF0000'
- name: yellow
hex: '#FFFF00'
- name: blue
hex: '#0000FF'
In assets/css/colors.scss, I want to create classes for the colors as follows:
{% for color in site.colors %}
.{{ color.name }} {
color: {{ color.hex }};
}
{% endfor %}
I want to #import the colors.scss file into main.scss, but I when I do so, I get the following error:
Error in _assets/css/background-test.scss:6 Invalid CSS after "}": expected selector or at-rule, was "{% for color in..."
Liquid Exception: Invalid CSS after "}": expected selector or at-rule, was "{% for color in..." in _includes/head.html, included in _layouts/default.html
jekyll 3.0.1 | Error: Invalid CSS after "}": expected selector or at-rule, was "{% for color in..."
Is there a way to get Liquid to process the values from the _config.yml file in the SCSS partial?
Only your main.scss will be parsed by Jekyll.
Once parsed with Liquid it is passed to sass/scss processor. So, any #imported file will not be parsed by Liquid.

Resources