Skip to content

CEP Validation Function check_cep Not Found #14

Description

@luigiazoreng

Description
The agt.utils.brazil.cep.validate() function is attempting to call a backend method check_cep that doesn't exist, resulting in a KeyError and ValidationError.

Error Traceback

17:32:29 web.1      | Traceback (most recent call last):
17:32:29 web.1      |   File "apps/frappe/frappe/handler.py", line 74, in execute_cmd
17:32:29 web.1      |     method = get_attr(cmd)
17:32:29 web.1      |              ^^^^^^^^^^^^^
17:32:29 web.1      |   File "apps/frappe/frappe/handler.py", line 297, in get_attr
17:32:29 web.1      |     method = globals()[cmd]
17:32:29 web.1      |              ~~~~~~~~~^^^^^
17:32:29 web.1      | KeyError: 'check_cep'
17:32:29 web.1      | 
17:32:29 web.1      | During handling of the above exception, another exception occurred:
17:32:29 web.1      | 
17:32:29 web.1      | Traceback (most recent call last):
17:32:29 web.1      |   File "apps/frappe/frappe/app.py", line 115, in application
17:32:29 web.1      |     response = frappe.api.handle(request)
17:32:29 web.1      |                ^^^^^^^^^^^^^^^^^^^^^^^^^^
17:32:29 web.1      |   File "apps/frappe/frappe/api/__init__.py", line 50, in handle
17:32:29 web.1      |     data = endpoint(**arguments)
17:32:29 web.1      |            ^^^^^^^^^^^^^^^^^^^^^
17:32:29 web.1      |   File "apps/frappe/frappe/api/v1.py", line 40, in handle_rpc_call
17:32:29 web.1      |     return frappe.handler.handle()
17:32:29 web.1      |            ^^^^^^^^^^^^^^^^^^^^^^^
17:32:29 web.1      |   File "apps/frappe/frappe/handler.py", line 52, in handle
17:32:29 web.1      |     data = execute_cmd(cmd)
17:32:29 web.1      |            ^^^^^^^^^^^^^^^^
17:32:29 web.1      |   File "apps/frappe/frappe/handler.py", line 76, in execute_cmd
17:32:29 web.1      |     frappe.throw(_("Failed to get method for command {0} with {1}").format(cmd, e))
17:32:29 web.1      |   File "apps/frappe/frappe/__init__.py", line 609, in throw
17:32:29 web.1      |     msgprint(
17:32:29 web.1      |   File "apps/frappe/frappe/__init__.py", line 574, in msgprint
17:32:29 web.1      |     _raise_exception()
17:32:29 web.1      |   File "apps/frappe/frappe/__init__.py", line 525, in _raise_exception
17:32:29 web.1      |     raise exc
17:32:29 web.1      | frappe.exceptions.ValidationError: Failed to get method for command check_cep with 'check_cep'

Expected Behavior
The agt.utils.brazil.cep.validate() function should successfully call the backend check_cep method to validate and fetch address information from the ViaCEP API.

Actual Behavior
A KeyError: 'check_cep' is raised because the backend method doesn't exist in the global scope.

Environment

  • OS: Debian GNU/Linux 12 (bookworm) (dev container)
  • Frappe Framework: V15
  • App: frappe_brazil_logistics
  • DocType: Carrier

Additional Context
The error suggests that the agt.utils.brazil.cep.validate() function expects a server-side method named check_cep to be available, but it hasn't been implemented or properly whitelisted with @frappe.whitelist() decorator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions