rust-lang/rust · error · anyhow::Error

file missing FileCopyrightText

Error message

file missing FileCopyrightText

What it means

Thrown by build_file_entry when a file section has a FileName but no FileCopyrightText tag was recorded. REUSE emits FileCopyrightText for every file (from SPDX-FileCopyrightText annotations or a default); its absence means the file lacks copyright metadata or REUSE failed to populate it.

Source

Thrown at src/tools/collect-license-metadata/src/spdx/mod.rs:97

        }
        text.push('\n');
        text.push_str(line);
    }

    anyhow::bail!("unexpected end of input inside <text> block")
}

fn build_file_entry(
    name: String,
    concluded_license: Option<String>,
    copyright_text: Option<String>,
) -> Result<SpdxFileEntry, Error> {
    Ok(SpdxFileEntry {
        name,
        concluded_license: concluded_license
            .ok_or_else(|| anyhow::anyhow!("file missing LicenseConcluded"))?,
        copyright_text: copyright_text
            .ok_or_else(|| anyhow::anyhow!("file missing FileCopyrightText"))?,
    })
}

#[cfg(test)]
mod tests;

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. Add an SPDX-FileCopyrightText annotation to the offending file (e.g. in its header or a .reuse/dep5 entry).
  2. Configure a default copyright in REUSE so uncovered files inherit it.
  3. Re-run REUSE and confirm FileCopyrightText now appears for the file.

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

// Count FileCopyrightText tags vs FileName tags.
let files = input.lines().filter(|l| l.starts_with("FileName:")).count();
let copyrights = input.lines().filter(|l| l.starts_with("FileCopyrightText:")).count();
if copyrights < files {
    eprintln!("{files} files but only {copyrights} FileCopyrightText tags; add copyright headers");
}

Try / catch

match crate::spdx::parse_tag_value(raw) {
    Err(e) if e.to_string().contains("missing FileCopyrightText") => {
        eprintln!("{e:#}. Add SPDX-FileCopyrightText to the offending file(s).");
        return Err(e);
    }
    other => other?,
}

Prevention

When it happens

Trigger: A tracked file has no SPDX-FileCopyrightText annotation and no applicable default copyright; REUSE was run in a mode that omits copyright; the file is new and headers were not added.

Common situations: New file committed without a copyright header; REUSE configuration missing a default copyright; a vendored third-party file without REUSE-compliant copyright info.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/c6182f8b75f8708b. Report an issue: GitHub.