Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid scheme format: '; dark' in /usr/src/app/_layouts/default.html #305

Closed
vincerubinetti opened this issue Jan 31, 2025 · 0 comments · Fixed by #308
Closed

Invalid scheme format: '; dark' in /usr/src/app/_layouts/default.html #305

vincerubinetti opened this issue Jan 31, 2025 · 0 comments · Fixed by #308

Comments

@vincerubinetti
Copy link
Collaborator

vincerubinetti commented Jan 31, 2025

Origination: greenelab/greenelab.com#139

Full error:

 Liquid Exception: Invalid scheme format: '; dark' in /usr/src/app/_layouts/default.html
bundler: failed to load command: jekyll (/usr/local/bundle/bin/jekyll)
/usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:917:in `scheme=': Invalid scheme format: '; dark' (Addressable::URI::InvalidURIError)
        from /usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:842:in `block in initialize'
        from /usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:2408:in `defer_validation'
        from /usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:839:in `initialize'
        from /usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `new'
        from /usr/local/bundle/gems/addressable-2.8.1/lib/addressable/uri.rb:152:in `parse'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/filters/url_filters.rb:75:in `compute_relative_url'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/filters/url_filters.rb:40:in `relative_url'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/strainer.rb:56:in `invoke'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/context.rb:86:in `invoke'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/variable.rb:84:in `block in render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `each'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `inject'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/variable.rb:82:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:80:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/if.rb:46:in `block (2 levels) in render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/if.rb:44:in `each'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/if.rb:44:in `block in render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/context.rb:123:in `stack'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/if.rb:43:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:82:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/for.rb:160:in `block (2 levels) in render_segment'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/for.rb:158:in `each'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/for.rb:158:in `block in render_segment'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/context.rb:123:in `stack'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/for.rb:150:in `render_segment'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/tags/for.rb:79:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:82:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:206:in `block in render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:240:in `with_profiling'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:205:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:218:in `render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:36:in `render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/inclusion.rb:16:in `render'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/tags/include.rb:208:in `block in render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/context.rb:123:in `stack'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/tags/include.rb:206:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:103:in `render_node_to_output'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/block_body.rb:91:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:206:in `block in render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:240:in `with_profiling'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:205:in `render'
        from /usr/local/bundle/gems/liquid-4.0.4/lib/liquid/template.rb:218:in `render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:39:in `block (3 levels) in render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:59:in `measure_counts'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:38:in `block (2 levels) in render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:63:in `measure_bytes'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:37:in `block in render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:70:in `measure_time'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/liquid_renderer/file.rb:36:in `render!'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:129:in `render_liquid'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:192:in `render_layout'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:161:in `place_in_layouts'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:93:in `render_document'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/renderer.rb:63:in `run'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:572:in `render_regenerated'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:564:in `block in render_pages'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:563:in `each'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:563:in `render_pages'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:211:in `render'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/site.rb:80:in `process'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:28:in `process_site'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:65:in `build'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/build.rb:36:in `process'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `each'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
        from /usr/local/bundle/gems/jekyll-4.3.2/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
        from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
        from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
        from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
        from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
        from /usr/local/bundle/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
        from /usr/local/bundle/gems/jekyll-4.3.2/exe/jekyll:15:in `<top (required)>'
        from /usr/local/bundle/bin/jekyll:25:in `load'
        from /usr/local/bundle/bin/jekyll:25:in `<top (required)>'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `load'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:58:in `kernel_load'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/cli/exec.rb:23:in `run'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/cli.rb:451:in `exec'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/cli.rb:34:in `dispatch'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/cli.rb:28:in `start'
        from /usr/local/bundle/gems/bundler-2.5.6/exe/bundle:28:in `block in <top (required)>'
        from /usr/local/bundle/gems/bundler-2.5.6/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
        from /usr/local/bundle/gems/bundler-2.5.6/exe/bundle:20:in `<top (required)>'
        from /usr/local/bundle/bin/bundle:25:in `load'
        from /usr/local/bundle/bin/bundle:25:in `<main>'

Starting from the current template version, to replicate this bug, add a section break component to a blog post, and remove any section breaks in the main blog/index.md page.

Then, from that starting point, do any one of the following to make the bug go away again:

  • Remove section from blog post
  • Add section to main blog page
  • Remove section from blog post and main blog page
  • Remove content=d.content from list.html
  • Remove data-search="{{ search }}" from post-excerpt.html
  • Use single post-excerpt.html on main blog page (with lookup param) instead of list component
  • Remove relative_url from style="--image: url('{{ image | relative_url | uri_escape }}')" in content.html

Consolidation/summary of the first three bullets: this bug only happens when section is not in main blog page, and is in blog post. The other 3 permutations of these two booleans are fine.

What appears to be happening is related to the section.html component and the non-conventional (by necessity) way that content.html captures the section component parameters.

The fix for this is probably replacing the e.g. "dark: (.*);" regexes in content.html with "dark: (.*?);", because it seems like the capture group is greedily matching too far, i.e. background: some-imageˇ; dark: true; size: pageˇ; (from ˇ to ˇ).

What I still don't understand, or just can't wrap my head around in my current mental state, is why I've never run into this before, and why the particular solutions bulleted above make the problem go away. This makes me uneasy that a "fix" for this won't be a true fix: some edge cases will remain error-prone, or something else new will break as a result.

vincerubinetti added a commit that referenced this issue Feb 3, 2025
Closes #305

This explanation is a bit hand-wavy, because I still can't follow the
logic exactly. I find it hard to debug the flow of things in Jekyll
because, while there's a `--trace` flag, the trace seems to be just the
under-the-hood Ruby code, and not e.g. "you used this `_include` in this
markdown file on this line, which then used this other `_include`, which
then ran this Ruby filter, etc.".

But in general: 

Certain nested content (I think within the `post-excerpt` hidden
`data-search` attribute) ended up making its way to `relative_url` in
`content.html` (which should just be a url), but only in certain rare
cases where the peculiarity of the regex matching in the `section`
component didn't prevent it.

- change regex matching of `section` params in `content.html` to
non-greedy, as they should've always been
- change string pattern of passing `section` params to `content.html`
from `param: value;` to `<param>value</param>`. this should reduce the
chances of incorrect parsing, because one of the params is a URL, which
can have `;` characters in them, which would confuse the old format.
- fix unrelated bug where home page tab title looks like `| Lab Website
Template` when it should just be `Lab Website Template` because the page
title is `""`
- strip all html from `post-excerpt` `data-search` attribute, as it
always should've been. is part of the main bug fix of this PR, but also
will reduce false-positive search matches, because without it,
`data-search` contains e.g. single `p` characters leftover from `<p>`
tags. now `data-search` should truly only be the content of the post.

While not fully understanding the full flow of the root issue here, I
think I've added enough safety mechanisms in enough spots to prevent
similar issues from occurring in the future.

New template version checklist:

- [x] I have updated CITATION and CHANGELOG as appropriate.
- [x] I have updated lab-website-template-docs as appropriate.
- [x] I have checked the testbed as appropriate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant