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

Treat certain user-caused errors as compilation failures #98

Merged
merged 3 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 1.2.0

* Have the compiler treat several user-generated invalid responses as
compilation errors rather than `ProtocolError`s:

* Invalid function signatures in `CompileRequest.global_functions`.

* Non-absolute URLs in `CanonicalizeResponse.result.url`,
`ImportSuccess.source_map_url`, and `FileImportResponse.result.file_url`.

* Clarify that an invalid signature in a `HostFunction` should treat the current
function as failing, rather than the `HostFunction`.

## 1.1.0

* Add a `charset` option that controls whether or not Sass emits a
Expand All @@ -7,17 +20,6 @@

* First stable release.

## 1.0.0-beta.18

* Add a `CompileRequest.source_map_include_sources` field that tells the
compiler to embed the contents of all source files in the generated source
maps.

## 1.0.0-beta.17

* Mark `ImportResponse.result` as optional. Importers should be able to return
`null` to indicate that a file wasn't found.

nex3 marked this conversation as resolved.
Show resolved Hide resolved
## 1.0.0-beta.16

* Mark `CompileFailure.span` as mandatory. There's no instance where a
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ not limited to:

* Sending a message with a `null` value for a mandatory field.

The `ProtocolError` message must *not* be used to report Sass errors or errors
running custom functions or importers.
The `ProtocolError` message must *not* be used to report Sass language errors.

### Host Language API

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.2.0
31 changes: 19 additions & 12 deletions embedded_sass.proto
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ message InboundMessage {
repeated Importer importers = 6;

// Signatures for custom global functions whose behavior is defined by the
// host. These must be valid Sass function signatures that could appear in
// after `@function` in a Sass stylesheet, such as
// `mix($color1, $color2, $weight: 50%)`.
// host.
//
// If this is not a valid Sass function signature that could appear after
// `@function` in a Sass stylesheet (such as `mix($color1, $color2, $weight:
// 50%)`), or if it conflicts with a function name that's built into the
// Sass language, the compiler must treat the compilation as failed.
//
// Compilers must ensure that pure-Sass functions take precedence over
// custom global functions. They must also reject any custom function names
// that conflict with function names built into the Sass language.
// custom global functions.
repeated string global_functions = 7;

// Whether to use terminal colors in the formatted message of errors and
Expand Down Expand Up @@ -141,8 +143,10 @@ message InboundMessage {
// that the importer either did not recognize the URL, or could not find a
// stylesheet at the location it referred to.
oneof result {
// The successfully canonicalized URL. This must be an absolute URL,
// including scheme.
// The successfully canonicalized URL.
//
// If this is not an absolute URL (including scheme), the compiler must
// treat that as an error thrown by the importer.
string url = 2;

// An error message explaining why canonicalization failed.
Expand Down Expand Up @@ -173,7 +177,8 @@ message InboundMessage {
// acceptable as well. If no URL is supplied, a `data:` URL is generated
// automatically from `contents`.
//
// If this is provided, it must be an absolute URL, including scheme.
// If this is provided and is not an absolute URL (including scheme) the
// compiler must treat that as an error thrown by the importer.
string source_map_url = 3;
}

Expand All @@ -200,9 +205,10 @@ message InboundMessage {
// The absolute `file:` URL to look for the file on the physical
// filesystem.
//
// The host must ensure that this URL follows the format for an absolute
// `file:` URL on the current operating system without a hostname, and the
// compiler must verify this to the best of its ability. See
// The compiler must verify to the best of its ability that this URL
// follows the format for an absolute `file:` URL on the current operating
// system without a hostname. If it doesn't, the compiler must treat that
// as an error thrown by the importer. See
// https://en.wikipedia.org/wiki/File_URI_scheme for details on the
// format.
//
Expand Down Expand Up @@ -836,7 +842,8 @@ message Value {
//
// If this isn't a valid Sass function signature that could appear after
// `@function` in a Sass stylesheet (such as `mix($color1, $color2, $weight:
// 50%)`), the compiler must treat the function's return value as invalid.
// 50%)`), the compiler must treat it as though the function that returned
// this `HostFunction` threw an error.
//
// > This ensures that the host doesn't need to be able to correctly parse
// > the entire function declaration syntax.
Expand Down