{"record":{"id":"cb746002dad93e45","repo":"tonhowtf/omniget","slug":"n-o-cifrei","errorCode":null,"errorMessage":"não cifrei: {}","messagePattern":"não cifrei: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/pdf_write.rs","lineNumber":171,"sourceCode":"                    Object::string_literal(id),\n                ]),\n            );\n        }\n        let filter: Arc<dyn CryptFilter> = Arc::new(Aes128CryptFilter);\n        let version = EncryptionVersion::V4 {\n            document: &doc,\n            encrypt_metadata: true,\n            crypt_filters: BTreeMap::from([(b\"StdCF\".to_vec(), filter)]),\n            stream_filter: b\"StdCF\".to_vec(),\n            string_filter: b\"StdCF\".to_vec(),\n            owner_password: owner,\n            user_password: &opts.user_password,\n            permissions: permissions_of(opts),\n        };\n        let state =\n            EncryptionState::try_from(version).map_err(|e| anyhow!(\"não montei a cifra: {}\", e))?;\n        doc.encrypt(&state)\n            .map_err(|e| anyhow!(\"não cifrei: {}\", e))?;\n        note = if opts.user_password.is_empty() {\n            \"permissões travadas (abre sem senha)\".into()\n        } else {\n            \"AES-128, senha para abrir\".into()\n        };\n    }\n    let out = out_path(\n        input,\n        &opts.output_dir,\n        &opts.suffix,\n        if opts.mode == \"remove\" {\n            \"-sem-senha\"\n        } else {\n            \"-protegido\"\n        },\n    )?;\n    doc.save(&out).map_err(|e| anyhow!(\"não gravei: {}\", e))?;\n    Ok(WriteItem {","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/pdf_write.rs#L153-L189","documentation":"Crypto failure in password_one: doc.encrypt with the AES-128 StdCF state returned an error — malformed document objects or unsupported prior encryption — so the PDF could not be secured and the item fails.","triggerScenarios":"doc.encrypt(&state) returns Err after EncryptionState was built successfully — typically an lopdf-internal problem computing the encryption dictionary/keys for this document.","commonSituations":"Unusual PDF structures (existing Encrypt remnants in the trailer) conflicting with the new state; lopdf version bugs; document loaded in a state where encryption cannot be applied.","solutions":["Read the wrapped inner lopdf error for the root cause","Ensure mode=\"remove\" was used first to strip any pre-existing Encrypt dictionary before re-encrypting","Update lopdf to the latest version for encryption fixes","Save to a fresh copy of the document and retry"],"exampleFix":"// before\ndoc.encrypt(&state).map_err(|e| anyhow!(\"não cifrei: {}\", e))?;\n// after\ndoc.trailer.remove(b\"Encrypt\"); // clear stale encryption dict first\ndoc.encrypt(&state).map_err(|e| anyhow!(\"falha ao cifrar PDF: {}\", e))?;","handlingStrategy":"try-catch","validationCode":"// remove stale encryption before re-encrypting\ndoc.trailer.remove(b\"Encrypt\");","typeGuard":null,"tryCatchPattern":"doc.encrypt(&state)\n    .map_err(|e| anyhow!(\"falha ao aplicar cifragem: {}\", e))?;","preventionTips":["Clear any existing Encrypt dictionary before applying a new one","Keep lopdf up to date for encryption bug fixes","Test encryption round-trip (save then re-load with password) in CI"],"tags":["pdf","encryption","lopdf"],"backgroundTag":"file-write-failed","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}