Blog

  • Azure Data Factory “Bad Request” null error

    Another reason for a “Bad Request” null – error in Azure Data Factory

    When creating a pipeline in Azure Data Factory to load data from Salesforce into a Fabric Lakehouse, I made contact with this glorious error message in ADF.

    I could pin it to my “Copy data” activity by setting breakpoints in my pipeline. But I had no idea what the reason for this message was. So, research the internet, reading StackOverflow and helpful articles like this: ADF: Error trying to debug pipeline: BadRequest where people have similar errors, most related to leading or trailing spaces or characters in parameter or variable names. I could rule that out since I checked that twice in my pipeline.

    So, I recreated the whole pipeline step by step and saved the resulting JSON in text files to see if anything changes in the background that I am unaware of in the GUI (you never know).

    The moment everything broke was when I removed an unused variable from my pipeline.

    Since I moved the object name from a variable to a parameter and replaced all occurrences in expressions and formulas, I removed the variable “objectname” from the pipeline. This is when the error popped up again—recreating the variable fixed it. So, the next logical step is “check if you forgot it somewhere in the pipeline”. And I didn’t… I checked the JSON of the pipeline, and it was nowhere.

    But then I found it, in a default value of a parameter of a dataset, used in the pipeline. Even though the default value was overwritten one the pipeline and not referenced at all.

    Lesson learned: If you remove a variable from a pipeline, ensure it is also removed from linked datasets parameter default values, even if you are not using the default value.

  • Validate Emails with RegEx

    The title of this article sounds like it shouldn’t be there, right? Because what’s so hard about validating an email address with RegEx? A lot, as I just learned.

    image source: quickmeme.com

    When I googled “regex for email validation” I found examples like this: /[^\s]*@[a-z0-9.-]*/i

    That one allows a lot, too much. Even double dots are okay for this expression. More than one dot in a row is neither allowed in the local part, the part in front of the @, nor in the domain part.

    Also, by definition, domain parts (the dot and the domain) are limited to 63 characters.

    Since all versions I found had flaws and ignored rules, I created my own and want to share the result.

    ^(?!.*\.{2,})[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])+?(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$

    This regular expression avoids double dots, quotation marks, and domain parts longer than 63 characters. It allows subdomains such as “.ca.gov” and all possible characters in the public and the domain part of the email address.

    Feel free to play with the regex on regexr.com/74ovj and let me know if you find a scenario that does not work.