Added log for avoid silent incoherence between user input and app behaviour - non-existing fields#189
Conversation
|
Test are not passing now since we have filtered the fields.. Incoming commit |
|
Now test are passing. We stored a set of strings as a class attribute ( Included debug logs following the constructor pattern. |
|
@dantuzi Lmk what you think and I'll rebase if needed |
| # Ask the endpoint the existing fields | ||
| schema_resp = requests.get(urljoin(self.endpoint.encoded_string(), 'schema/fields')).json() | ||
| # subset only the present fields | ||
| self.schema_fields = {field['name'] for field in schema_resp.get('fields', [])} |
There was a problem hiding this comment.
I don't see self.schema_fields used somewhere. Am I wrong?
There was a problem hiding this comment.
If this is needed only in this small piece of code, schema_fields should be a local variable
There was a problem hiding this comment.
I think it might be useful for checking the payload when building the queries to the engine
| # In unit tests the mock response may not contain the expected structure -> store empty set | ||
| log.debug(f"Schema fields endpoint did not return expected payload: {exc}; defaulting to empty schema list") | ||
| self.schema_fields = set() | ||
| log.debug(f"Schema fields loaded: {len(self.schema_fields)} fields found.") |
There was a problem hiding this comment.
It looks like this entire PR is for writing this string in the logs. Why do you think this is useful?
There was a problem hiding this comment.
I as developer / user rather knowing when some fields are present or not, than just executing and expect to behave nice. The problem was the silent omission of fields if not present on the schema
There was a problem hiding this comment.
Another option could be implementing this directly on the _search method. Maybe makes more sense. But I'd like to know when the searched fields are not present
Added:
This: 1)notice in the logs which fields are present in the index. 2) Subset only the valid ones. Might need aditional logic to handle empty cases. let me know if you agree with the approach.