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

proposed changes on empty value handling for opensanctions search #863

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

Pascal-Delange
Copy link
Contributor

@Pascal-Delange Pascal-Delange commented Feb 19, 2025

The diff got kind of big, but the premise here is basically:

  • opensanctions errors out (400) if it returns a query with only empty search inputs
  • so we want to handle a search with empty string in the same way as null value read, on our side
  • so I'm also making the concatenation ast node return an empty string if it receives no inputs (or only nil inputs). There could be a point to be made to return nil if it only receives nils ? but I'm not sure if it's worth it

}
}

if nullFieldRead >= 2 {
if emptyFieldRead == nbEvaluatedFields {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this condition was incorrect if one of the two inputs was left empty

@@ -43,9 +43,5 @@ func (f StringConcat) Evaluate(ctx context.Context, arguments ast.Arguments) (an
}
}

if sb.Len() == 0 {
return MakeEvaluateError(ast.ErrNullFieldRead)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we actually used to have a lot of those, they have been rather deprecated in favor of "cleanly" returning nil in Evaluate if a nil value is "read" (AKA some nil received in a required input or actual nil value read in the logic of the function)

@apognu
Copy link
Contributor

apognu commented Feb 19, 2025

I was not able to reproduce manually the 400 on empty inputs, do you have the query JSON handy?

@Pascal-Delange
Copy link
Contributor Author

I was not able to reproduce manually the 400 on empty inputs, do you have the query JSON handy?

Hmm no, I'll check a bit later

@Pascal-Delange
Copy link
Contributor Author

I was not able to reproduce manually the 400 on empty inputs, do you have the query JSON handy?

@apognu in short what seems to happens in the main branch is that in some cases at least we are left with an empty slice of queries, for which yente returns a 400 code.
When only empty strings were received, no proper queries for OS were generated

@Pascal-Delange Pascal-Delange force-pushed the pascal/fix-os-empty-input branch from 7b0cf1b to 7f69d12 Compare February 19, 2025 13:52
@Pascal-Delange Pascal-Delange enabled auto-merge (rebase) February 19, 2025 13:52
@Pascal-Delange Pascal-Delange merged commit ecf83e6 into main Feb 19, 2025
2 checks passed
@Pascal-Delange Pascal-Delange deleted the pascal/fix-os-empty-input branch February 19, 2025 13:54
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