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

fix: account for un-checked Article 4 values in GIS API #4066

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

jessicamcinchak
Copy link
Member

@jessicamcinchak jessicamcinchak commented Dec 11, 2024

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good spot by Jenna!

Now that constraints are optional, I think we actually need to also update the type to reflect this on line 148. I'd guess there's a few other places in this file we're working from the assumption that all constraints will be returned?

I think it's just a case of adding Partial<T> here -

  // --- INTERSECTIONS ---
  // check for & add any 'positive' constraints to the formattedResult
  let formattedResult: Partial<Record<string, Constraint>> = {};

Copy link

github-actions bot commented Dec 11, 2024

Removed vultr server and associated DNS entries

@jessicamcinchak
Copy link
Member Author

jessicamcinchak commented Dec 11, 2024

Now that constraints are optional, I think we actually need to also update the type to reflect this on line 148. I'd guess there's a few other places in this file we're working from the assumption that all constraints will be returned?

I think it's just a case of adding Partial<T> here -

  // --- INTERSECTIONS ---
  // check for & add any 'positive' constraints to the formattedResult
  let formattedResult: Partial<Record<string, Constraint>> = {};

Good question @DafyddLlyr - but the constraints response type never checks actual key/property names returned (here nor ODP Schema) because this varies depending on each councils Article 4s (and can be actual 100s of varying keys depending on council)! So this type is still correct as-is based because Constraint here is simply describing the properties expected for each item returned, not actual key/property names -

Screenshot from 2024-12-11 11-55-10

August and I had really sweated the designated, listed, and flood parent/child cases but missed this article4/article4.caz one.

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for example requests - this shows this fixes the problem 👍 Approved and happy to merge so we can keep testing.

I've just checked this out a bit more and I think the Partial<> is most correct - currently the type says all strings are valid keys and will have a corresponding Constraint. I know we're not defining them per-dataset here but adding Partial<> would illustrate that it's not all strings that are valid keys, just some undeclared subset.

The current type allows this -

image

If we add Partial it would have caught the issue Jenna flagged as a type error -

image

There are a few more cascading type fixes that fall out from this change though (hopefully just adding more optional chaining) - happy for this to be a fix later / have on the radar issue as opposed to blocking this fix.

@jessicamcinchak jessicamcinchak merged commit 79b90d9 into main Dec 11, 2024
12 checks passed
@jessicamcinchak jessicamcinchak deleted the jess/fix-gis-a4-type-error branch December 11, 2024 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants