Table of Contents

    Book an Appointment

    INTRODUCTION

    While working on an inventory automation initiative for a manufacturing and supply chain enterprise, we encountered a deceptively simple bug that caused critical failures in production. The system was designed to orchestrate procurement alerts by extracting raw material data from a cloud-hosted spreadsheet, evaluating the stock levels, and dispatching alerts directly to the procurement team via MS Teams.

    During the user acceptance testing phase, warehouse managers noticed a dangerous discrepancy. Certain raw materials that had definitively dropped below their designated safety stock levels were not triggering an alert. The workflow was executing without throwing any obvious errors, yet the output was mathematically incorrect.

    When enterprise systems rely on low-code or workflow automation tools like n8n, silent failures in logic routing are far more dangerous than outright crashes. A workflow that executes flawlessly but routes data incorrectly can lead to severe operational blind spots—in this case, halting a manufacturing line due to a lack of raw materials. This challenge inspired the following deep dive into how seemingly simple node configurations can mask complex data typing issues, so other teams can avoid the same mistake.

    PROBLEM CONTEXT

    The business use case was straightforward: build an automated, low-latency pipeline to monitor inventory. The architecture relied on an n8n workflow that ran on a scheduled trigger. The workflow integrated with Microsoft OneDrive to download an Excel sheet containing real-time inventory metrics, parsed the rows into JSON objects, and passed them through an IF node.

    The IF node contained the core business logic: evaluate if Current Stock is less than Safety Stock. If the condition evaluated to true, the workflow routed the payload to an MS Teams integration node to notify the purchasing department.

    However, the execution logs painted a confusing picture. Out of a sample batch of four materials, manual calculation showed that three of them fulfilled the condition. Yet, the IF node only routed two materials down the true branch. The third material bypassed the alert completely, silently exiting via the false branch. In a production environment handling thousands of SKUs, this inconsistency would be disastrous.

    WHAT WENT WRONG

    We began by isolating the IF node and inspecting the data moving between the spreadsheet extraction node and the evaluation logic. On the surface, the n8n UI displayed the extracted data as a clean tabular format. There were no malformed rows, no missing columns, and no network timeouts.

    The bottleneck was an architectural oversight regarding how n8n—and underlying JavaScript engines—handle implicit type coercion when parsing spreadsheet data.

    Spreadsheet APIs often return numerical data as formatted strings rather than pure integers or floats, especially if the cells in Excel contain custom formatting, commas, or varying decimal places. When n8n’s IF node received this data, it processed the condition using string comparison rules rather than mathematical numeric comparison.

    In JavaScript string comparison, characters are evaluated sequentially by their lexicographical (dictionary) value. For example, if a material has a Current Stock of "9" and a Safety Stock of "10", the string comparison "9" < "10" evaluates to false (because the character ‘9’ is greater than ‘1’). Mathematically, 9 is less than 10, meaning this item should have triggered an alert. Instead, it was filtered out, leading to our missing alerts.

    HOW WE APPROACHED THE SOLUTION

    Our diagnostic process required us to peel back the visual abstraction of the low-code tool and inspect the raw JSON payload. By switching the n8n data viewer from “Table” to “JSON”, we confirmed the hypothesis: the numbers were wrapped in quotes.

    We evaluated several approaches to solve this:

    • Modifying the Source Data: We could enforce strict data validation rules on the Excel file itself. However, this relies on end-user compliance and is prone to human error.
    • Type Casting in the IF Node: We could configure the IF node to strictly compare the values as numbers. While n8n allows you to specify the data type in the IF node configuration (e.g., Number vs. String), unexpected characters (like commas in “1,000”) would still result in a NaN (Not a Number) evaluation.
    • Implementing a Data Sanitization Layer: The most robust architectural decision was to introduce a sanitization step before the logic evaluation. This guarantees that all downstream nodes interact with strongly typed, clean data.
    • We opted for the data sanitization layer. Enterprise integrations demand predictability, which is exactly why tech leaders choose to hire software developer teams capable of treating low-code platforms with traditional engineering rigor.

    FINAL IMPLEMENTATION

    To implement the fix, we inserted a “Set” node (or alternatively, a “Code” node for complex transformations) immediately after the Excel extraction step and before the IF node. This node was responsible for stripping any formatting characters and explicitly casting the string values into integers or floating-point numbers.

    Data Sanitization Expression

    We used n8n’s built-in expression engine to parse the values. Here is the technical configuration applied to the values:

    // Example n8n expression to safely parse Excel string numbers
    {{ parseFloat($json['Current Stock'].toString().replace(/,/g, '')) || 0 }}
    {{ parseFloat($json['Safety Stock'].toString().replace(/,/g, '')) || 0 }}
    

    Updating the IF Node

    Once the sanitization node guaranteed the outputs were pure numbers, we updated the IF node configuration:

    • Condition Type: Number
    • Value 1: {{ $json.current_stock_clean }}
    • Operation: Smaller
    • Value 2: {{ $json.safety_stock_clean }}

    Validation Steps

    We reran the workflow against the original dataset. The IF node successfully processed all four materials, accurately routing the three low-stock items down the true branch and passing them to the MS Teams node. We also injected edge cases—such as empty cells, extremely large numbers with comma formatting, and negative values—to verify the robustness of the parseFloat logic.

    LESSONS FOR ENGINEERING TEAMS

    Treating low-code tools like traditional codebases is critical for production reliability. Here are actionable insights engineering teams should apply when orchestrating complex automation:

    • Never Trust Source Data: Whether extracting from an API, a database, or a spreadsheet, assume data types are fluid until explicitly cast. Implement sanitization layers early in the pipeline.
    • Understand Underlying Engines: Low-code platforms abstract complexity but do not eliminate it. Knowing that n8n evaluates expressions using Node.js allows you to predict JS-specific quirks, like lexicographical string comparisons.
    • Inspect Raw JSON: Visual table views can hide data type realities. Always debug using the raw JSON view to spot trailing spaces, string wrappers, or null values.
    • Implement Fallbacks: When casting data, always provide a fallback value (e.g., || 0) to prevent the entire workflow from crashing if an upstream user leaves a spreadsheet cell completely blank.
    • Hire Expertise for Critical Paths: When automations drive supply chain continuity, visual programming requires traditional architectural oversight. This is why companies look to hire automation developers for enterprise workflows who understand data structures, error handling, and scalable design.
    • Abstract Configuration: If you scale this to dozens of workflows, consider writing a reusable sub-workflow solely dedicated to standardizing and cleaning ERP or spreadsheet data before it enters the main logic engine.

    WRAP UP

    What appeared to be an arbitrary failure in an n8n routing node was ultimately a fundamental lesson in data type coercion. By implementing explicit type casting and a dedicated data sanitization layer, we transformed a fragile automation into a highly reliable enterprise alert system. Complex integrations require engineers who look past visual interfaces and debug at the foundational data level. Whether you need to hire n8n developers for scalable automation or are looking to hire backend developers for system integrations, our team is equipped to deliver robust solutions.

    Social Hashtags

    #n8n #WorkflowAutomation #LowCode #AutomationEngineering #DevOps #APIAutomation #BackendDevelopment #NodeJS #DataEngineering #SystemIntegration #AutomationTools #LowCodeDevelopment #AIWorkflows #TechDebugging #SoftwareEngineering

    If you are struggling with unpredictable system behavior or need to scale your automation architecture, contact us.

    Frequently Asked Questions