Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Version 2019.3.6139 breaks Django templates #1289

Closed
DonJayamanne opened this issue Apr 1, 2019 · 6 comments
Closed

Version 2019.3.6139 breaks Django templates #1289

DonJayamanne opened this issue Apr 1, 2019 · 6 comments

Comments

@DonJayamanne
Copy link
Contributor

@amaliaman commented on Sun Mar 31 2019

Environment data

  • VS Code version: 1.32.3
  • Extension version (available under the Extensions sidebar): 2019.3.6139
  • OS and version: Win 10 Home x64
  • Python version (& distribution if applicable, e.g. Anaconda): Python 2.7.15 32-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: N/A

Expected behaviour

Until version 2019.3.5558, django templates rendered correctly, variables passed between templates were received ok

Actual behaviour

Since version 2019.3.6139 the system crashes on start, variables are not transferred to target templates:

Exception has occurred: VariableDoesNotExist
Failed lookup for key [chat_mode] in ...

Steps to reproduce:

  1. Upgrade the extension and reload
  2. Start debug
  3. Get error message:
Exception has occurred: VariableDoesNotExist
Failed lookup for key [chat_mode] in ...

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Jedi Python language engine.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

extensionService.ts:788 Couldn't find message for key python.snippet.launch.unitTests.description.
_logMessageInConsole @ extensionService.ts:788
extensionHost.ts:330 [Extension Host] debugger listening on port 10046
console.ts:134 [Extension Host] Looking for parseable documents...
console.ts:134 [Extension Host] Found all parseable documents.
console.ts:134 [Extension Host] Parsing documents and looking for CSS class definitions...
log.ts:161  INFO no standard startup: not a new window
console.ts:134 [Extension Host] Summary:
console.ts:134 [Extension Host]% 289 parseable documents found
console.ts:134 [Extension Host]% 133276 CSS class definitions found
console.ts:134 [Extension Host]% 1351 unique CSS class definitions found
console.ts:134 [Extension Host]% 3 failed attempts to parse. List of the documents:
console.ts:134 [Extension Host] /d:/dev/peacock/peacock/peacock/react-components/node_modules/cssnano-preset-default/node_modules/postcss-discard-overridden/src/__tests__/fixtures/keyframes.css
/d:/dev/peacock/peacock/peacock/react-components/node_modules/serve-index/public/directory.html
/d:/dev/peacock/peacock/peacock/templates/test/turntable.html

webviewElement.ts:284 [Embedded Page] Refused to apply inline style because it violates the following Content Security Policy directive: "style-src vscode-core-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-0E9jHYRsQadToqRYKhY0Cwfum9vhLdNKr8UJ5QOE+6o='), or a nonce ('nonce-...') is required to enable inline execution.

extensionService.ts:788 Couldn't find message for key python.snippet.launch.unitTests.description.
_logMessageInConsole @ extensionService.ts:788
console.ts:134 [Extension Host] (node:2936) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
@fabioz
Copy link
Contributor

fabioz commented Apr 1, 2019

@amaliaman can you provide a case to reproduce this error? I've tried with a sample code here and was not able to reproduce... also, can you provide the full stack trace as well as the django version you're using?

@amaliaman
Copy link

amaliaman commented Apr 3, 2019

@fabioz

Django Version

1.6.1

Use Case

Parent template (view.html) has:

{% include 'common/invite-modal.html' with chat_mode=True %}

Included template (invite-modal.html) has:

{% if chat_mode %}{% trans 'Start a chat' %}{% else %}

Until the update, view.html was rendered OK with invite-modal.html included and its contents were rendered according to chat_mode=True ('Start a chat'.) After the update the app crashes, claiming chat_mode does not exist in invite-modal.html:

Exception has occurred: VariableDoesNotExist
Failed lookup for key [chat_mode] in ...

This happens with all template variables.

@fabioz
Copy link
Contributor

fabioz commented Apr 3, 2019

The oldest Django we test with is 1.7, which is likely the reason this broke (although I'll at least add a test with the use-case with includes).

@karthiknadig Django 1.6 is no longer officially supported since 2015: https://www.djangoproject.com/download/#supported-versions... so, I'm a little unsure whether we want to support it, what do you think?

@amaliaman do you want to use breakpoints/exception breakpoints in Django templates or just in regular Python code? -- I think that if you don't want the breakpoints in Django templates, just removing Django options from your launch should work.

@amaliaman
Copy link

@fabioz removing "django": true in launch.json solved the problem, we don't need Django breakpoints at the moment. Thanks!

@karthiknadig
Copy link
Member

@fabioz 1.7 and greater should be fine.

@qubitron qubitron added this to the April 2019.1 milestone Apr 3, 2019
@fabioz
Copy link
Contributor

fabioz commented Apr 4, 2019

I'm closing this one in favor of #1276 (that one seems to have the same issue but with 2.1.7).

@fabioz fabioz closed this as completed Apr 4, 2019
karthiknadig pushed a commit that referenced this issue Apr 4, 2019
…ixes #1298, #1294 (#1310)

* Django 2.2 tests and fixes for exception breakpoints in Django 1.7. Fixes #1289, #1294

* Don't report variable errors silenced by django. Fixes #1276
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants