get-*-source functions raise exception when filename includes a relative path #228

Closed
opened 5 years ago by otherjoel · 2 comments
otherjoel commented 5 years ago (Migrated from github.com)

In an empty folder, create example.html.pm, a folder sub/ and a file sub/another.html.pm. (The files can be empty, created with touch) Then in the base folder, create the following pollen.rkt:

#lang racket

(require pollen/file)

(get-markup-source "example.html")
(get-markup-source "sub/another.html")

Expected output:

#<path:example.html.pm>
#<path:sub/another.html.pm>

Actual output:

#<path:example.html.pm>
../../../Library/Racket/7.7/pkgs/pollen/pollen/setup.rkt:21:0: path->complete-path: second argument is not a complete path
  first argument: #<path:pollen.rkt>
  second argument: #<path:sub/>
context...:
   /Users/joel/Library/Racket/7.7/pkgs/pollen/pollen/setup.rkt:21:0: get-path-to-override
   /Users/joel/Library/Racket/7.7/pkgs/pollen/pollen/setup.rkt:48:11: poly-targets
   /Users/joel/Library/Racket/7.7/pkgs/pollen/pollen/private/file-utils.rkt:164:11: get-markup-source
   /Users/joel/Documents/code/sandbox/pollen.rkt:1:1 [running body]

Important to note, this happens even when there is a sub/pollen.rkt that provides a valid setup module.

It looks like this is due to these recent changes in pollen/setup.rkt surfacing a possible bug in get-path-to-override.

When get-path-to-override is called with a relative path+file, the relative “folders” part is passed unmodified into path->complete-path where it raises the above exception because it is not a complete path.

The functions generated by define-settable call the get-path-to-override function. Prior to 912ba088b this call was inside with-handlers. The bug in this function causes an exn:fail:contract? exception to be raised even when a valid sub/pollen.rkt exists, but it was caught by the handler so no error surfaced to the user.

In an empty folder, create `example.html.pm`, a folder `sub/` and a file `sub/another.html.pm`. (The files can be empty, created with `touch`) Then in the base folder, create the following `pollen.rkt`: ```racket #lang racket (require pollen/file) (get-markup-source "example.html") (get-markup-source "sub/another.html") ``` **Expected output:** ```racket #<path:example.html.pm> #<path:sub/another.html.pm> ``` **Actual output:** ``` #<path:example.html.pm> ../../../Library/Racket/7.7/pkgs/pollen/pollen/setup.rkt:21:0: path->complete-path: second argument is not a complete path first argument: #<path:pollen.rkt> second argument: #<path:sub/> context...: /Users/joel/Library/Racket/7.7/pkgs/pollen/pollen/setup.rkt:21:0: get-path-to-override /Users/joel/Library/Racket/7.7/pkgs/pollen/pollen/setup.rkt:48:11: poly-targets /Users/joel/Library/Racket/7.7/pkgs/pollen/pollen/private/file-utils.rkt:164:11: get-markup-source /Users/joel/Documents/code/sandbox/pollen.rkt:1:1 [running body] ``` Important to note, this happens even when there is a `sub/pollen.rkt` that provides a valid `setup` module. It looks like this is due to [these recent changes][1] in `pollen/setup.rkt` surfacing a possible bug in `get-path-to-override`. When `get-path-to-override` is called with a relative path+file, the relative “folders” part is passed unmodified into `path->complete-path` where it raises the above exception because it is not a complete path. The functions generated by `define-settable` call the `get-path-to-override` function. Prior to 912ba088b this call was inside `with-handlers`. The bug in this function causes an `exn:fail:contract?` exception to be raised even when a valid `sub/pollen.rkt` exists, but it was caught by the handler so no error surfaced to the user. [1]: https://github.com/mbutterick/pollen/commit/912ba088bf038393714d5795799462f3774c78f4#diff-459945571fbaabc584e76cb5f380c832L46-R60
mbutterick commented 5 years ago (Migrated from github.com)

Thanks! Yes, that with-handlers was incorrectly suppressing some legitimate bugs (not all of which I’ve discovered yet, clearly)

Thanks! Yes, that `with-handlers` was incorrectly suppressing some legitimate bugs (not all of which I’ve discovered yet, clearly)
otherjoel commented 5 years ago (Migrated from github.com)

Thank you!

Thank you!
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#228
Loading…
There is no content yet.