website
website copied to clipboard
[infra] Erro de validação no external_link quando algum campo é required
Descrição
Ao tentar publicar os metadados de uma tabela bdm recebo um erro de validação do external_link que esta com os campos dataset_id e url como required, ao tornar os campos optional o erro desaparece. O mesmo n acontece com information_request que tbm tem o campo dataset_id como required.
Comando
import basedosdados as bd
md = bd.Metadata(dataset_id='teste_teste', table_id='teste_teste')
md.create(if_exists='replace',table_only=False)
md.publish(if_exists='replace',all=True)
Erro
---------------------------------------------------------------------------
BaseDosDadosException Traceback (most recent call last)
~/gabinite_sv/bd+/mais/python-package/basedosdados/upload/metadata.py in publish(self, all, if_exists, update_locally)
412 try:
--> 413 self.validate()
414
~/gabinite_sv/bd+/mais/python-package/basedosdados/upload/metadata.py in validate(self)
353 message = f"{self.filepath} has validation errors: {error}"
--> 354 raise BaseDosDadosException(message)
355
BaseDosDadosException: /Users/m/gabinite_sv/bd+/mais/bases/aopsdkpokasdppoaskd/dataset_config.yaml has validation errors: {'aopsdkpokasdppoaskd': [{'loc': ['resources', 0, 'ExternalLink', 'url'], 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ['resources', 0, 'ExternalLink', 'dataset_id'], 'msg': 'field required', 'type': 'value_error.missing'}]}
During handling of the above exception, another exception occurred:
BaseDosDadosException Traceback (most recent call last)
~/gabinite_sv/bd+/mais/python-package/basedosdados/upload/metadata.py in publish(self, all, if_exists, update_locally)
427 if all:
--> 428 self.dataset_metadata_obj.publish(if_exists=if_exists)
429
~/gabinite_sv/bd+/mais/python-package/basedosdados/upload/metadata.py in publish(self, all, if_exists, update_locally)
460 )
--> 461 raise BaseDosDadosException(message)
462
BaseDosDadosException: Could not publish metadata due to a validation error. Please see the traceback below to get information on how to correct it.
BaseDosDadosException("/Users/m/gabinite_sv/bd+/mais/bases/aopsdkpokasdppoaskd/dataset_config.yaml has validation errors: {'aopsdkpokasdppoaskd': [{'loc': ['resources', 0, 'ExternalLink', 'url'], 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ['resources', 0, 'ExternalLink', 'dataset_id'], 'msg': 'field required', 'type': 'value_error.missing'}]}")
During handling of the above exception, another exception occurred:
BaseDosDadosException Traceback (most recent call last)
/var/folders/71/tpcbz38n2xs1q_96jb1sdmrw0000gn/T/ipykernel_59868/636235756.py in <module>
1 # md.create()
2
----> 3 md.publish(if_exists='replace',all=True)
~/gabinite_sv/bd+/mais/python-package/basedosdados/upload/metadata.py in publish(self, all, if_exists, update_locally)
459 f"ect it.\n\n{repr(e)}"
460 )
--> 461 raise BaseDosDadosException(message)
462
463 except NotAuthorized as e:
BaseDosDadosException: Could not publish metadata due to a validation error. Please see the traceback below to get information on how to correct it.
BaseDosDadosException('Could not publish metadata due to a validation error. Please see the traceback below to get information on how to correct it.\n\nBaseDosDadosException("/Users/m/gabinite_sv/bd+/mais/bases/aopsdkpokasdppoaskd/dataset_config.yaml has validation errors: {\'aopsdkpokasdppoaskd\': [{\'loc\': [\'resources\', 0, \'ExternalLink\', \'url\'], \'msg\': \'field required\', \'type\': \'value_error.missing\'}, {\'loc\': [\'resources\', 0, \'ExternalLink\', \'dataset_id\'], \'msg\': \'field required\', \'type\': \'value_error.missing\'}]}")')
Resolvemos isso né?
Nop, a gente só desviou do problema kkkk