gleam-lang/gleam · warning

Source files missing SPDX licence information! Add a…

Error message

Source files missing SPDX licence information!

Add a comment like this:

    // SPDX-License-Identifier: Apache-2.0
    // SPDX-FileCopyrightText: 2026 The Gleam contributors

To these files:

- {paths}

What it means

This is a deliberate test-guard panic in the Gleam compiler's test suite (`all_files_have_copyright_notice`). It scans source files and panics when any file lacks the required SPDX licence header comments. It exists to enforce a repository-wide licensing policy: every source file must carry an `SPDX-License-Identifier` and `SPDX-FileCopyrightText` comment so licensing metadata is machine-readable.

Solutions

  1. Add the two SPDX comment lines at the very top of each listed file: `// SPDX-License-Identifier: Apache-2.0` and `// SPDX-FileCopyrightText: 2026 The Gleam contributors`.
  2. Set up an editor snippet, file template, or `cargo fmt`-adjacent pre-commit hook that inserts the header automatically for new .rs files.
  3. If a listed file is generated code, add it to the test's allowlist/ignore list (or configure a licence header tool like `license-header` / `add-license-headers`) rather than editing generated output directly.
  4. Re-run the test to confirm the panic no longer fires and the file list is empty.

Example fix

// before (src/new_module.rs)
pub fn new_module() {}

// after
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2026 The Gleam contributors
pub fn new_module() {}
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
# check-spdx.sh — run before committing
for f in $(git ls-files '*.rs'); do
  head -n 3 "$f" | grep -q 'SPDX-License-Identifier' || echo "missing SPDX: $f"
done

Prevention

When it happens

Trigger: Running the Gleam test suite (the `all_files_have_copyright_notice` test, defined around compiler-core/src/tests.rs:186) after adding or generating a new .rs source file without SPDX header comments at the top of the file.

Common situations: A contributor creates a new module or test file and forgets the header; a code generator or scaffolding tool writes files without headers; files copied from another project retain a different (or no) licence header; a file header was accidentally removed during a refactor or merge conflict resolution.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of gleam-lang/gleam@15b07c7830 (2026-09-14). Data as JSON: /api/errors/6655ade334905d45. Report an issue: GitHub.

Appendix: source

Thrown at compiler-core/src/tests.rs:186

                "html" if path.starts_with("../compiler-core/templates/") => (),

                _ => panic!("Unexpected file extension for {path:?}"),
            };

            let text = std::fs::read_to_string(&path).expect("read file");
            if text.contains("SPDX-License-Identifier: Apache-2.0")
                && text.contains("SPDX-FileCopyrightText: 20")
            {
                // Licence information is present
                return None;
            }

            Some(path.to_str().unwrap().to_string())
        })
        .join("\n - ");

    if !paths.is_empty() {
        panic!(
            "Source files missing SPDX licence information!

Add a comment like this:

    // SPDX-License-Identifier: Apache-2.0
    // SPDX-FileCopyrightText: 2026 The Gleam contributors

To these files:

- {paths}
"
        )
    }
}

View on GitHub (pinned to 15b07c7830)