tonhowtf/omniget · error

página

Error message

página: {}

What it means

In rasterize_page (pdf_redact.rs), after adding the rasterized stream, doc.get_dictionary_mut(page_id) failed, wrapped as 'página: {}'. The page object could not be fetched as a mutable dictionary, so the content/resources cannot be swapped in.

Solutions

  1. Re-resolve the page id from doc.get_pages() just before mutation instead of caching ids
  2. Check the wrapped lopdf error for 'object not found' vs type errors
  3. Run a repair/rewrite pass (load and save with lopdf) on suspect PDFs before redacting

Example fix

// before
let page = doc.get_dictionary_mut(page_id).map_err(|e| anyhow!("página: {}", e))?;
// after
let pages = doc.get_pages();
if !pages.values().any(|id| *id == page_id) { bail!("page object {} missing", page_id.0); }
let page = doc.get_dictionary_mut(page_id).map_err(|e| anyhow!("página: {}", e))?;
Defensive patterns

Strategy: type-guard

Validate before calling

let page_ids: Vec<_> = doc.get_pages().into_values().collect();
if !page_ids.contains(&page_id) { bail!("page id {:?} not in document", page_id); }

Type guard

fn page_is_dict(doc: &lopdf::Document, id: lopdf::ObjectId) -> bool {
    matches!(doc.get_object(id), Ok(lopdf::Object::Dictionary(_)))
}

Prevention

When it happens

Trigger: page_id no longer resolves (freed/rewritten object), the page object is not a dictionary (e.g. an indirect reference chain lopdf won't follow), or the id belongs to another object after earlier mutations.

Common situations: Redacting pages of an unusual/corrupt PDF whose page tree lopdf parses imperfectly; object renumbering during save/load cycles invalidating stored ids.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/a4992b28b361d490. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/pdf_redact.rs:651

                    Object::Real(h),
                    Object::Real(media[0]),
                    Object::Real(media[1]),
                ],
            ),
            Operation::new("Do", vec!["OGRXimg".into()]),
            Operation::new("Q", vec![]),
        ],
    };
    let stream_id = doc.add_object(Stream::new(
        dictionary! {},
        content.encode().map_err(|e| anyhow!("conteúdo: {}", e))?,
    ));
    let res_id = doc.add_object(Object::Dictionary(dictionary! {
        "XObject" => dictionary! { "OGRXimg" => Object::Reference(img_id) },
    }));
    let page = doc
        .get_dictionary_mut(page_id)
        .map_err(|e| anyhow!("página: {}", e))?;
    page.set("Contents", Object::Reference(stream_id));
    page.set("Resources", Object::Reference(res_id));
    page.remove(b"Annots");
    Ok(())
}

/// Tira as anotações que encostam na região: um campo de formulário ou uma
/// nota grudada ali carrega o texto de novo.
fn drop_annots(doc: &mut Document, page_id: lopdf::ObjectId, rects: &[Rect]) {
    let annots = match doc.get_dictionary(page_id).and_then(|p| p.get(b"Annots")) {
        Ok(Object::Array(a)) => a.clone(),
        Ok(Object::Reference(r)) => match doc.get_object(*r) {
            Ok(Object::Array(a)) => a.clone(),
            _ => return,
        },
        _ => return,
    };
    let hits = |dict: &lopdf::Dictionary| -> bool {

View on GitHub (pinned to 8600b91f42)