Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is-ip dependency update issue #3765

Open
busma13 opened this issue Sep 20, 2024 · 0 comments
Open

is-ip dependency update issue #3765

busma13 opened this issue Sep 20, 2024 · 0 comments
Assignees
Labels
bug dependencies Pull requests that update a dependency file

Comments

@busma13
Copy link
Contributor

busma13 commented Sep 20, 2024

Currently we are on [email protected]. We were held back because of ESM. Current is 5.0.1.

Updating to this version breaks tests that check to see if null is an IP addresses. Expected result is false, but a change in 5.0.1 checks the length of the parameter we pass in, resulting in an error.

I feel like the library should catch a null value and return false. If others agree I will open an issue. Otherwise we might need to add null checks around the isIP function.
EDIT: After walking through some code with Joseph, I think we need to check types whenever we call this function. The logicBuilder function gets too complicated for typescript to realize the types don't match.

Updating to 5.0.0 should be possible.

 FAIL   data-mate  packages/data-mate/test/matcher/document-matcher-spec.ts
  Document-Matcher
    ✓ should not mutate the original data (7 ms)
    normal mode
      when testing ip queries
        can do ip type annotations with crazy data
          ✕ should be able to match on query ipField:"192.198.0.0/24" (27 ms)
    filterNil mode
      when testing ip queries
        can do ip type annotations with crazy data
          ✕ should be able to match on query ipField:"192.198.0.0/24" (4 ms)

  ● Document-Matcher › normal mode › when testing ip queries › can do ip type annotations with crazy data › should be able to match on query ipField:"192.198.0.0/24"

    TypeError: Cannot read properties of null (reading 'length')

      84 |             return checkCidr(ip, range);
      85 |         }
    > 86 |         if (isIP(ip)) return range.contains(ip);
         |             ^
      87 |         return false;
      88 |     };
      89 | }

      at length (node_modules/is-ip/index.js:12:13)
      at isIP (packages/data-mate/src/document-matcher/logic-builder/ip.ts:86:13)
      at DocumentMatcher.cb [as filterFn] (packages/data-mate/src/document-matcher/logic-builder/index.ts:47:16)
      at DocumentMatcher.filterFn [as match] (packages/data-mate/src/document-matcher/index.ts:23:21)
      at match (packages/data-mate/test/matcher/document-matcher-spec.ts:21:80)
          at Array.map (<anonymous>)
      at Object.map (packages/data-mate/test/matcher/document-matcher-spec.ts:21:46)

  ● Document-Matcher › filterNil mode › when testing ip queries › can do ip type annotations with crazy data › should be able to match on query ipField:"192.198.0.0/24"

    TypeError: Cannot read properties of null (reading 'length')

      84 |             return checkCidr(ip, range);
      85 |         }
    > 86 |         if (isIP(ip)) return range.contains(ip);
         |             ^
      87 |         return false;
      88 |     };
      89 | }

      at length (node_modules/is-ip/index.js:12:13)
      at isIP (packages/data-mate/src/document-matcher/logic-builder/ip.ts:86:13)
      at DocumentMatcher.cb [as filterFn] (packages/data-mate/src/document-matcher/logic-builder/index.ts:47:16)
      at DocumentMatcher.filterFn [as match] (packages/data-mate/src/document-matcher/index.ts:23:21)
      at match (packages/data-mate/test/matcher/document-matcher-spec.ts:21:80)
          at Array.map (<anonymous>)
      at Object.map (packages/data-mate/test/matcher/document-matcher-spec.ts:21:46)
@busma13 busma13 added bug dependencies Pull requests that update a dependency file labels Sep 20, 2024
@busma13 busma13 self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

1 participant