<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pelumi Oluwategbe</title>
    <description>The latest articles on DEV Community by Pelumi Oluwategbe (@pelsky1).</description>
    <link>https://dev.to/pelsky1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F847276%2Faa580bc1-c6c3-4f2d-826e-a7ab2ca63d8d.png</url>
      <title>DEV Community: Pelumi Oluwategbe</title>
      <link>https://dev.to/pelsky1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pelsky1"/>
    <language>en</language>
    <item>
      <title>Building Mithridatium: Detecting Hidden Backdoors in ML Models</title>
      <dc:creator>Pelumi Oluwategbe</dc:creator>
      <pubDate>Wed, 06 May 2026 19:36:25 +0000</pubDate>
      <link>https://dev.to/pelsky1/building-mithridatium-detecting-hidden-backdoors-in-ml-models-3gh7</link>
      <guid>https://dev.to/pelsky1/building-mithridatium-detecting-hidden-backdoors-in-ml-models-3gh7</guid>
      <description>&lt;p&gt;As pretrained AI models become more common, one growing concern is whether those models can actually be trusted.&lt;/p&gt;

&lt;p&gt;A model may appear completely normal during testing, but behave maliciously when exposed to a hidden trigger. These attacks are known as backdoor or poisoning attacks, and they represent a serious security risk for real-world AI systems.&lt;/p&gt;

&lt;p&gt;This semester, our team built &lt;strong&gt;Mithridatium&lt;/strong&gt; - an open-source framework designed to help detect hidden backdoors in pretrained machine learning models.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fow3bvb0ilr832d7znhy8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fow3bvb0ilr832d7znhy8.png" alt="Mithridatium Landing Page" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Backdoor?
&lt;/h2&gt;

&lt;p&gt;In simple terms, a backdoor attack hides malicious behavior inside an otherwise normal model.&lt;/p&gt;

&lt;p&gt;Most of the time, the model behaves exactly as expected. But when a specific trigger appears in the input, the model changes its behavior in a way that benefits an attacker.&lt;/p&gt;

&lt;p&gt;Imagine a self-driving vehicle that correctly recognizes stop signs during testing, but misclassifies them when a small sticker or visual trigger is placed on the sign. A hidden trigger like this could potentially cause extremely dangerous outcomes in real-world systems.&lt;/p&gt;

&lt;p&gt;This problem becomes even more concerning because many developers rely heavily on pretrained models downloaded from external sources like Hugging Face or public repositories.&lt;/p&gt;

&lt;p&gt;The question becomes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How do we verify that a pretrained model has not been poisoned before deploying it?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the problem Mithridatium was designed to explore.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F261jrqioj98tc773ks6s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F261jrqioj98tc773ks6s.png" alt="Example of a backdoor attack" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Mithridatium Does
&lt;/h2&gt;

&lt;p&gt;Mithridatium is a framework for evaluating pretrained image classification models for potential backdoor behavior.&lt;/p&gt;

&lt;p&gt;The framework allows users to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load local checkpoints or Hugging Face models&lt;/li&gt;
&lt;li&gt;Run multiple backdoor detection defenses&lt;/li&gt;
&lt;li&gt;Generate structured JSON reports&lt;/li&gt;
&lt;li&gt;Visualize results through a web demo interface&lt;/li&gt;
&lt;li&gt;Compare detection signals across different methods&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is to translate AI security research into practical and reusable tooling.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3le8zhvel9s8bn81rknd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3le8zhvel9s8bn81rknd.png" alt="Mithridatium Pipeline" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Detection Defenses
&lt;/h2&gt;

&lt;p&gt;One of the most interesting parts of the project was implementing and evaluating several different detection strategies. Each defense approaches the problem differently.&lt;/p&gt;

&lt;h3&gt;
  
  
  FreeEagle
&lt;/h3&gt;

&lt;p&gt;FreeEagle is a white-box, data-free defense.&lt;/p&gt;

&lt;p&gt;Instead of relying on datasets or trigger injection, it analyzes the internal behavior of the model itself and looks for abnormal class bias patterns that may indicate hidden backdoor behavior.&lt;/p&gt;

&lt;p&gt;This makes it especially useful for quickly screening unknown models.&lt;/p&gt;

&lt;h3&gt;
  
  
  STRIP
&lt;/h3&gt;

&lt;p&gt;STRIP works by perturbing inputs with other images.&lt;/p&gt;

&lt;p&gt;The intuition is that a normal model should become less confident when the input changes significantly. However, backdoored models often remain unusually stable when the trigger is present.&lt;/p&gt;

&lt;p&gt;If prediction entropy remains suspiciously low across perturbed inputs, STRIP raises a red flag.&lt;/p&gt;

&lt;h3&gt;
  
  
  MMBD
&lt;/h3&gt;

&lt;p&gt;MMBD focuses on abnormal dominance patterns across output classes.&lt;/p&gt;

&lt;p&gt;The defense looks for suspicious concentration or bias in the model’s behavior that may suggest hidden trigger relationships.&lt;/p&gt;

&lt;p&gt;This approach was especially interesting because it worked well even against some dynamic backdoor scenarios.&lt;/p&gt;

&lt;h3&gt;
  
  
  AEVA
&lt;/h3&gt;

&lt;p&gt;AEVA takes a more adversarial approach.&lt;/p&gt;

&lt;p&gt;It perturbs input images and observes how the model responds to trigger-like changes. By analyzing anomaly indices and perturbation behavior, the framework can identify suspicious patterns associated with backdoors.&lt;/p&gt;

&lt;p&gt;Compared to some other defenses, AEVA can require significantly more queries and computation, especially in black-box settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the Project
&lt;/h2&gt;

&lt;p&gt;Mithridatium was built primarily in Python using PyTorch and Hugging Face tooling.&lt;/p&gt;

&lt;p&gt;The project currently includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A modular CLI interface&lt;/li&gt;
&lt;li&gt;Support for Hugging Face models&lt;/li&gt;
&lt;li&gt;JSON report generation&lt;/li&gt;
&lt;li&gt;Multiple detection defenses&lt;/li&gt;
&lt;li&gt;Demo interfaces for visualization&lt;/li&gt;
&lt;li&gt;Compatibility validation for supported architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A typical CLI run looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mithridatium detect &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--model&lt;/span&gt; models/resnet18_cifar10.pt &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data&lt;/span&gt; cifar10 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--defense&lt;/span&gt; freeeagle &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--out&lt;/span&gt; reports/freeeagle_report.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--force&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The framework can also evaluate models directly from Hugging Face using model IDs instead of local checkpoints.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reports and Visual Output
&lt;/h2&gt;

&lt;p&gt;One major goal of the project was usability.&lt;/p&gt;

&lt;p&gt;A user should not need to read multiple research papers just to understand whether a model might be risky. Mithridatium attempts to translate complex detection signals into understandable verdicts and metrics.&lt;/p&gt;

&lt;p&gt;The framework produces structured reports and can visualize outputs through the demo interface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuo01f3l67nk63wrq9kpd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuo01f3l67nk63wrq9kpd.png" alt="Demo UI Example" width="800" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;One thing we learned very quickly is that ML security tooling is not just about implementing algorithms.&lt;/p&gt;

&lt;p&gt;A practical tool also has to handle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;dataset compatibility&lt;/li&gt;
&lt;li&gt;integration problems&lt;/li&gt;
&lt;li&gt;reporting&lt;/li&gt;
&lt;li&gt;usability&lt;/li&gt;
&lt;li&gt;deployment assumptions&lt;/li&gt;
&lt;li&gt;benchmarking&lt;/li&gt;
&lt;li&gt;reproducibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One particularly important lesson involved dataset mismatch.&lt;/p&gt;

&lt;p&gt;Some defenses behaved very differently depending on whether the evaluation dataset matched the dataset the model was originally trained on. In some cases, mismatched datasets produced false positives that initially looked like detection failures.&lt;/p&gt;

&lt;p&gt;We also learned that different defenses come with different tradeoffs.&lt;/p&gt;

&lt;p&gt;Some methods are lightweight and data-free, while others require large numbers of model queries or significant computational resources.&lt;/p&gt;

&lt;p&gt;Another major takeaway was the importance of clear reporting. Security tooling becomes far more useful when results are understandable to developers who may not specialize in AI security research.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current Developers
&lt;/h2&gt;

&lt;p&gt;Mithridatium was developed through Open Source with SLU by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pelumi Oluwategbe&lt;/li&gt;
&lt;li&gt;Gustavo Lucca&lt;/li&gt;
&lt;li&gt;Payton Guffey&lt;/li&gt;
&lt;li&gt;Will Phoenix&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Project Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Repository: &lt;a href="https://github.com/oss-slu/mithridatium" rel="noopener noreferrer"&gt;https://github.com/oss-slu/mithridatium&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Project Website: &lt;a href="https://mithridatium.vercel.app/" rel="noopener noreferrer"&gt;https://mithridatium.vercel.app/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hugging Face Demo: &lt;a href="https://huggingface.co/spaces/williamphoenix/Mithridatium" rel="noopener noreferrer"&gt;https://huggingface.co/spaces/williamphoenix/Mithridatium&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Looking Ahead
&lt;/h2&gt;

&lt;p&gt;Mithridatium currently focuses on image classification models, but the broader concept of model integrity verification is much larger.&lt;/p&gt;

&lt;p&gt;As AI systems become more widely deployed, verifying pretrained models before deployment will likely become increasingly important.&lt;/p&gt;

&lt;p&gt;This project represents one small step toward making AI security tooling more practical, accessible, and open source.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>cybersecurity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Mithridatium: An Open-Source Toolkit for Verifying the Integrity of Pretrained Machine Learning Models</title>
      <dc:creator>Pelumi Oluwategbe</dc:creator>
      <pubDate>Wed, 03 Dec 2025 02:53:48 +0000</pubDate>
      <link>https://dev.to/pelsky1/mithridatium-an-open-source-toolkit-for-verifying-the-integrity-of-pretrained-machine-learning-38g</link>
      <guid>https://dev.to/pelsky1/mithridatium-an-open-source-toolkit-for-verifying-the-integrity-of-pretrained-machine-learning-38g</guid>
      <description>&lt;p&gt;Modern machine learning workflows rely heavily on pretrained models—downloaded from GitHub, HuggingFace, and countless other model hubs. This convenience comes with a growing risk: model tampering, data poisoning, and hidden backdoors embedded in .pth checkpoints.&lt;/p&gt;

&lt;p&gt;To address this problem, we built Mithridatium, a lightweight open-source framework designed to verify the integrity of pretrained neural networks before they enter production or research pipelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Mithridatium?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today’s ML ecosystem assumes that pretrained models are safe. In reality, the model file itself can be a silent attack vector:&lt;br&gt;
    • poisoned training data&lt;br&gt;
    • hidden triggers that activate under specific inputs&lt;br&gt;
    • manipulated weights&lt;br&gt;
    • malformed checkpoints that cause unexpected runtime behavior&lt;/p&gt;

&lt;p&gt;Mithridatium provides a command-line workflow to evaluate these risks through model-centric defenses, inspired by academic research, but simplified for real-world use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Offline Usage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once installed, Mithridatium can run entirely offline.&lt;/p&gt;

&lt;p&gt;You only need:&lt;br&gt;
    1.  Your .pth model file&lt;br&gt;
    2.  A local dataset directory (optional for STRIP; required for MMBD depending on configuration)&lt;/p&gt;

&lt;p&gt;This makes the tool suitable for restricted environments, air-gapped machines, or secure internal ML pipelines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Install from PyPI:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install mithridatium&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Upgrade to the latest release:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install --upgrade mithridatium&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implemented Defenses&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;MMBD (Maximum Mean Backdoor Detection)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;MMBD evaluates synthetic class-optimized images to detect anomalous activation patterns commonly associated with backdoored models.&lt;/p&gt;

&lt;p&gt;The implementation exposes:&lt;br&gt;
    • per-class eigenvalue scores&lt;br&gt;
    • normalized anomaly distributions&lt;br&gt;
    • classical hypothesis testing (p-value)&lt;br&gt;
    • a deterministic verdict&lt;/p&gt;

&lt;p&gt;Example invocation in our tool:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mithridatium detect --model model.pth --defense mmbd --arch resnet18 --data cifar10&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;STRIP (Strong Intentional Perturbation)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;STRIP is a black-box defense: it does not rely on internal architectural details. Instead, it evaluates the prediction entropy when the model is exposed to heavily perturbed variants of the same input. Backdoored models typically exhibit abnormally low entropy under perturbation, due to a forced output toward the trigger class.&lt;/p&gt;

&lt;p&gt;Our implementation includes:&lt;br&gt;
    • entropy computation on perturbed samples&lt;br&gt;
    • sampling and perturbation utilities&lt;br&gt;
    • summary metrics (mean, min, max entropy)&lt;br&gt;
    • integration into a unified reporting schema&lt;/p&gt;

&lt;p&gt;Example invocation in our tool:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mithridatium detect --defense strip --model model.pth --data cifar10 --arch resnet18&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recent Advancements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most recent development cycle added the following enhancements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;STRIP Core Utility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A modular implementation inside defenses/strip.py that handles entropy scoring, perturbation generation, and device-safe execution (CPU/MPS/CUDA).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CLI Integration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;STRIP can now be invoked just like MMBD, with unified reporting and JSON output.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Output Schema Normalization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’re standardizing all defenses toward a single report format to enable ecosystem integration.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;End-to-End CLI Tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full test coverage ensures STRIP runs cleanly through subprocess without crashes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What’s Next&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the major defenses complete, the remaining work is focused on:&lt;br&gt;
    • improving documentation&lt;br&gt;
    • adding developer notes&lt;br&gt;
    • refining report summaries&lt;br&gt;
    • strengthening validation and error messaging&lt;/p&gt;

&lt;p&gt;We’re not adding new defenses till next year; instead, we’re polishing the tool so it is maintainable and accessible to new contributors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try it Yourself&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project is open-source and available here:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="//github.com/oss-slu/mithridatium"&gt;mithridatium&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contributions, issues, and feedback are welcome.&lt;br&gt;
If you’re working with pretrained models—research, deployment, or security, you should not assume integrity. Mithridatium helps you verify it. You can read detailed explanations, defense theory, and usage examples in the repository’s README.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>security</category>
      <category>neuralnetworks</category>
    </item>
    <item>
      <title>MERN Stack Learning path</title>
      <dc:creator>Pelumi Oluwategbe</dc:creator>
      <pubDate>Tue, 17 Jan 2023 18:27:19 +0000</pubDate>
      <link>https://dev.to/pelsky1/mern-stack-learning-path-5eo2</link>
      <guid>https://dev.to/pelsky1/mern-stack-learning-path-5eo2</guid>
      <description>&lt;p&gt;Been a long time I wrote, but here I am. Hopefully I'll write more these days. So in my React journey (also learning Node JS along), I started this tutorial building a social media application and I'm currently at the back end part of it. I was stuck in one aspect for hourssss. Left it, watched a movie to clear my mind and came back but I still didn't get it. I even asked ChatGPT lol (it must've been tired of me today if it could get tired). Tried different methods and stuff. What I was trying to achieve was updating a particular post and I was testing the function on the postman app. Code snippet below: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8fip1vqo3uchnjvgeqh4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8fip1vqo3uchnjvgeqh4.PNG" alt=" " width="626" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I followed the tutorial well, and it just wasn't working. The console gave the error below: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zug4ms4nbi98oisa560.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zug4ms4nbi98oisa560.PNG" alt=" " width="684" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So after googling and asking ChatGPT for help, I found out that BSON error means that the arguments passed in the url wasn't complete so I checked my Postman url again and noticed that there was a new line after the url and wondered how in the world I could've missed such. Picture below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9x3c8rinz6dtk7e5ezkh.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9x3c8rinz6dtk7e5ezkh.PNG" alt=" " width="800" height="515"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's amazing how a simple error set me back and I'm currently pissed at myself for that, but then it's all part of the learning journey so it's cool. So whoever is reading this, don't give up. If your code isn't working, check over and over again. Don't forget the details. Alright, till next time.&lt;/p&gt;

</description>
      <category>mern</category>
      <category>webdev</category>
      <category>react</category>
      <category>node</category>
    </item>
    <item>
      <title>How to convert html to pdf (something like a generated invoice) and send it to an email</title>
      <dc:creator>Pelumi Oluwategbe</dc:creator>
      <pubDate>Sat, 16 Jul 2022 10:45:49 +0000</pubDate>
      <link>https://dev.to/pelsky1/how-to-convert-html-to-pdf-something-like-a-generated-invoice-and-send-it-to-an-email-728</link>
      <guid>https://dev.to/pelsky1/how-to-convert-html-to-pdf-something-like-a-generated-invoice-and-send-it-to-an-email-728</guid>
      <description>&lt;p&gt;Long time, no post. Sorry about that, been quite busy with my youth service PPA (Place of Primary Assignment), and sadly it has taken quite so much of my time. Anyways, down to business. So I'm building this web application for my PPA which generates a delivery note from a set of inputs and sends to the inputed email by the click of the "Send Email" button. I had problems with converting it to a pdf and I did a lot of research but I finally figured it out with the help of the internet and some people at Stack Overflow (every junior developer needs help from the internet), to convert it to pdf and print by the click of a button, here's the code below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdyx6nj8ghdn5mlbfsdps.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdyx6nj8ghdn5mlbfsdps.PNG" alt="Code to convert html to pdf" width="800" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So you have to add the html2pdf script before it can work, though there are other ways, this was the one I found.&lt;br&gt;
Meanwhile if you want to generate a pdf and then send it to an email, that is a different ball game. I tried fetching the downloaded pdf and then sending it to the email, but that gave me problems and I couldn't quite figure it out. Anyways, I did some research and also asked other senior developers I knew for help (Special thanks, Mr Samuel Adetoro &lt;a class="mentioned-user" href="https://dev.to/big_black_fella"&gt;@big_black_fella&lt;/a&gt; ). So I found smtpJs and followed the steps shown below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdz7hekrb7c2q7ksmfik.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdz7hekrb7c2q7ksmfik.PNG" alt="smtpJs snippets on sending attachments to email" width="646" height="704"&gt;&lt;/a&gt;&lt;br&gt;
As you can see in the highlighted part, I could send an email with attachment but the code to convert and send a pdf straight was more complex than that so I did some further research and also found some help from some guys at Stack Overflow and to avoid long talk, I had to create an Elastic email account shown below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8jo13fwgy8pv2es6wput.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8jo13fwgy8pv2es6wput.PNG" alt="My Elastic Email account" width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I combined it with the smtpjs code and also the html2pdf code to convert the invoice to a pdf, then change it to a datauristring and then send it as a data using the email code from smtpjs. I used elastic email as my smtp server. The code is shown below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6k75wnz5co58jjsv7usw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6k75wnz5co58jjsv7usw.PNG" alt="JS code to convert html to pdf and then send as an attachment to email" width="800" height="479"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, it all worked out and the invoice looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ue84tvla1jysek2dxs3.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ue84tvla1jysek2dxs3.PNG" alt="The Invoice generated" width="800" height="353"&gt;&lt;/a&gt;.&lt;br&gt;
It was successfully sent to the email that was inputed. That's all from me for now, till next time. Hope you found this useful.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>New Journey</title>
      <dc:creator>Pelumi Oluwategbe</dc:creator>
      <pubDate>Thu, 14 Apr 2022 09:12:59 +0000</pubDate>
      <link>https://dev.to/pelsky1/new-journey-3j5h</link>
      <guid>https://dev.to/pelsky1/new-journey-3j5h</guid>
      <description>&lt;p&gt;Hey Guys, this is my first post as I just joined dev.to. So a role model of mine advised me to maybe start writing, as per document my programming journey and I thought: yeah, that's a great idea as it would even push me to learn more regularly even with the other things I'm so busy with (service year...ugh). So here I am, and I'm looking forward to taking you guys along in my journey.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
