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

HTML rendering error: nothing should not be printed #156

Closed
Ankur-deDev opened this issue Aug 7, 2019 · 12 comments
Closed

HTML rendering error: nothing should not be printed #156

Ankur-deDev opened this issue Aug 7, 2019 · 12 comments
Assignees

Comments

@Ankur-deDev
Copy link

Ankur-deDev commented Aug 7, 2019

Describe the bug
I am following the Bill Gates book example here and got the error:

ERROR: ArgumentError: nothing should not be printed; use show, repr, or custom output instead.

To Reproduce

  • Follow Bill Gates book example.
  • Replace html! with html (as html! does not exists, but not sure if this is correct).
  • Within the app directory, in Julia execute the following command.
    using Genie; Genie.loadapp(); using BooksController; BooksController.billgatesbooks()

Expected behavior
I am not sure whether this error is a wrong behavior.

Additional context
versioninfo()
Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, skylake)
Environment:
JULIA_REVISE = auto

pkg> st
Status ~/Tester/Project.toml
[c43c736e] Genie v0.10.1
[682c06a0] JSON v0.21.0
[39ec1447] Millboard v0.2.0
[295af30f] Revise v2.1.6

Stack
ERROR: ArgumentError: nothing should not be printed; use show, repr, or custom output instead.
Stacktrace:

[1] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing) at ./show.jl:566
[2] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing, ::String) at ./strings/io.jl:42
[3] normal_element(::Array{Union{Nothing, String},1}, ::String) at /home/user/.julia/packages/Genie/LHtIg/src/Flax.jl:140
[4] normal_element(::getfield(Genie.Renderer, Symbol("##33#37")), ::String, ::Array{Pair{Symbol,Any},1}) at /home/user/.julia/packages/Genie/LHtIg/src/Flax.jl:116
[5] #body#36 at ./none:2 [inlined]
[6] body at ./none:2 [inlined]
[7] (::getfield(Genie.Renderer, Symbol("##30#34")))() at /home/user/Books/build/FlaxViews/a61fb571d6f0fc6e87fc97c269d5d6c775adde87.jl:4
[8] normal_element at /home/user/.julia/packages/Genie/LHtIg/src/Flax.jl:116 [inlined]
[9] #html#32 at ./none:2 [inlined]
[10] #html at ./none:0 [inlined]
[11] func_a61fb571d6f0fc6e87fc97c269d5d6c775adde87() at /home/user/Books/build/FlaxViews/a61fb571d6f0fc6e87fc97c269d5d6c775adde87.jl:4
[12] #invokelatest#1 at ./essentials.jl:697 [inlined]
[13] invokelatest at ./essentials.jl:696 [inlined]
[14] |> at ./operators.jl:813 [inlined]
[15] #tohtml#2(::Symbol, ::Module, ::Base.Iterators.Pairs{Symbol,Array{BooksController.Book,1},Tuple{Symbol},NamedTuple{(:books,),Tuple{Array{BooksController.Book,1}}}}, ::Function, ::Symbol, ::Symbol) at /home/user/.julia/packages/Genie/LHtIg/src/Renderer.jl:52

@essenciary
Copy link
Member

@Ankur-deDev Sorry, I need to update that, the API has been massively updated recently, in preparation for v1. I'll take a look and update the README.

@essenciary
Copy link
Member

@Ankur-deDev I took a look, I think the only thing needed was to just replace html! and json! with html and json. I updated and pushed the docs.

@Ankur-deDev
Copy link
Author

Thanks for your quick action.
I moved my .julia and tried again, but got an error earlier with the following steps:

pkg> add Genie
julia> using Genie
julia> Genie.newapp("Repro")
ERROR: IOError: open: no such file or directory (ENOENT)
Stacktrace:
 [1] uv_error at ./libuv.jl:85 [inlined]
 [2] open(::String, ::UInt8, ::Int64) at ./filesystem.jl:81
 [3] open at ./filesystem.jl:73 [inlined]
 [4] sendfile(::String, ::String) at ./file.jl:743
 [5] #cp#12(::Bool, ::Bool, ::Function, ::String, ::String) at ./file.jl:336
 [6] cp at ./file.jl:330 [inlined]
 [7] copy_microstack_app(::String) at /home/user/.julia/packages/Genie/NB11Y/src/REPL.jl:36
 [8] #newapp#7(::Bool, ::Bool, ::Bool, ::Function, ::String) at /home/user/.julia/packages/Genie/NB11Y/src/REPL.jl:150
 [9] #newapp at ./none:0 [inlined]
 [10] #newapp#15 at /home/user/.julia/packages/Genie/NB11Y/src/Genie.jl:92 [inlined]
 [11] newapp(::String) at /home/user/.julia/packages/Genie/NB11Y/src/Genie.jl:92
 [12] top-level scope at none:0

(v1.0) pkg> st
    Status `~/.julia/environments/v1.0/Project.toml`
  [c43c736e] Genie v0.11.1

@essenciary
Copy link
Member

essenciary commented Aug 8, 2019

@Ankur-deDev Sorry, yes, completely unrelated issue :-/ Can you please update to latest master?

pkg> add https://github.com/GenieFramework/Genie.jl

Until the new v0.13.1 will be registered.

@Ankur-deDev
Copy link
Author

Great, I tried with the new version and was able to create the app.
I followed the books example again, and it works fine as long as the HTML is in the controller.
Once I follow the steps here to render the view I get back the original error:

julia> using Genie; Genie.loadapp(); 
 _____         _
|   __|___ ___|_|___
|  |  | -_|   | | -_|
|_____|___|_|_|_|___|

┌ Info: 
│ Starting Genie in >> DEV << mode 
└ 
[ Info: Logging to file at /home/user/Repro/log/dev.log 
[ Info: Recompiling stale cache file /home/user/.julia/compiled/v1.1/BooksController.ji for BooksController [top-level]

julia> using BooksController

julia> BooksController.billgatesbooks()
2019-08-09 09:21:52:DEBUG:Main: 🚨  Flax view app/resources/books/views/billgatesbooks.jl.html build build/FlaxViews/8f5e1d5a4b008396d4cd553ad4a7c2a06f9eb7c7.jl is stale
2019-08-09 09:21:53:DEBUG:Main: 🚨  Flax view app/layouts/app.jl.html build build/FlaxViews/a61fb571d6f0fc6e87fc97c269d5d6c775adde87.jl is stale
ERROR: ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.
Stacktrace:
 [1] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing) at ./show.jl:566
 [2] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing, ::String) at ./strings/io.jl:42
 [3] normal_element(::Array{Union{Nothing, String},1}, ::String) at /home/user/.julia/packages/Genie/chAqw/src/Flax.jl:135
 [4] normal_element(::getfield(Genie.Renderer, Symbol("##30#34")), ::String, ::Array{Pair{Symbol,Any},1}) at /home/user/.julia/packages/Genie/chAqw/src/Flax.jl:111
 [5] #body#34(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Function) at ./none:2
 [6] body at ./none:2 [inlined]
 [7] (::getfield(Genie.Renderer, Symbol("##27#31")))() at /home/user/Repro/build/FlaxViews/a61fb571d6f0fc6e87fc97c269d5d6c775adde87.jl:4
 [8] normal_element at /home/user/.julia/packages/Genie/chAqw/src/Flax.jl:111 [inlined]
 [9] #html#30 at ./none:2 [inlined]
 [10] #html at ./none:0 [inlined]
 [11] func_a61fb571d6f0fc6e87fc97c269d5d6c775adde87() at /home/user/Repro/build/FlaxViews/a61fb571d6f0fc6e87fc97c269d5d6c775adde87.jl:4
 [12] #invokelatest#1 at ./essentials.jl:742 [inlined]
 [13] invokelatest at ./essentials.jl:741 [inlined]
 [14] |> at ./operators.jl:813 [inlined]
 [15] #tohtml#2(::Symbol, ::Module, ::Base.Iterators.Pairs{Symbol,Array{BooksController.Book,1},Tuple{Symbol},NamedTuple{(:books,),Tuple{Array{BooksController.Book,1}}}}, ::Function, ::Symbol, ::Symbol) at /home/user/.julia/packages/Genie/chAqw/src/Renderer.jl:54
 [16] #tohtml at ./none:0 [inlined]
 [17] #html#5(::Symbol, ::Module, ::Int64, ::Dict{String,String}, ::Base.Iterators.Pairs{Symbol,Array{BooksController.Book,1},Tuple{Symbol},NamedTuple{(:books,),Tuple{Array{BooksController.Book,1}}}}, ::Function, ::Symbol, ::Symbol) at /home/user/.julia/packages/Genie/chAqw/src/Renderer.jl:68
 [18] (::getfield(Genie.Renderer, Symbol("#kw##html")))(::NamedTuple{(:books,),Tuple{Array{BooksController.Book,1}}}, ::typeof(Genie.Renderer.html), ::Symbol, ::Symbol) at ./none:0
 [19] billgatesbooks() at /home/user/Repro/app/resources/books/BooksController.jl:19
 [20] top-level scope at none:0

The last commit in JuliaLang/julia/base/show.jl could be related to that.

@essenciary
Copy link
Member

essenciary commented Aug 9, 2019

@Ankur-deDev I can't reproduce - I have a slightly different version of the test app which works fine.

julia> BooksController.billgatesbooks()
2019-08-09 09:58:28:DEBUG:Main:SQL QUERY: SELECT "books"."id" AS "books_id", "books"."title" AS "books_title", "books"."author" AS "books_author", "books"."cover" AS "books_cover" FROM "books" ORDER BY books.id ASC
  0.186826 seconds (426.70 k allocations: 21.421 MiB, 6.84% gc time)
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Content-Type: text/html

<html lang="en" ><head ><title >Genie Admin</title></head><body ><h1 >Books admin</h1><h1 >Bill Gates' top 7 "recommended books!!"</h1><ul ><li ><p >The Best We Could Do by Thi Bui</p></li><li ><p >Evicted: Poverty and Profit in the American City by Matthew Desmond</p></li><li ><p >Believe Me: A Memoir of Love, Death, and Jazz Chickens by Eddie Izzard</p></li><li ><p >The Sympathizer! by Viet Thanh Nguyen</p></li><li ><p >Energy and Civilization, A History by Vaclav Smil</p></li><li ><p >Leonardo da Vinci by Walter Isaacson</p></li><li ><p >Identity by Francis Fukuyama</p></li></ul></body></html>"""

Can you please zip the whole app and share it with me?

@Ankur-deDev
Copy link
Author

Hi, Thanks a lot for having a look, I have sent you the tarball.

@essenciary
Copy link
Member

@Ankur-deDev Thanks - where is it?

@essenciary
Copy link
Member

This was actually caused by a sneaky bug, sorry for it. Should be all fixed on the latest #master!

@essenciary
Copy link
Member

Closing this as it should be resolved on the latest master. Please reopen if that's not the case.

@Ankur-deDev
Copy link
Author

I confirm it is working as expected now. Thanks a lot for the quick fix!

I had sent the tarball to the address defined in GenieFramework/Genie.jl/Project.toml but it was rejected with the following message (sorry for not realizing earlier that the mail did not go through):

SMTP error from remote mail server after end of data:
552-5.7.0 This message was blocked because its content presents a potential
552-5.7.0 security issue. Please visit
552-5.7.0 https://support.google.com/mail/?p=BlockedMessage to review our
552 5.7.0 message content and attachment content guidelines. o4si32831595ejn.27 - gsmtp

@essenciary
Copy link
Member

@Ankur-deDev Thanks for the update, happy that it works now!

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

No branches or pull requests

2 participants