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

Could not build url for endpoint 'dcat.read_catalog' #230

Closed
student2017USA opened this issue Aug 16, 2022 · 5 comments · Fixed by #259
Closed

Could not build url for endpoint 'dcat.read_catalog' #230

student2017USA opened this issue Aug 16, 2022 · 5 comments · Fixed by #259

Comments

@student2017USA
Copy link

After installing ckanext-dcat, i enabled it in ckan.ini by adding following in ckan.plugins

dcat dcat_json_harvester dcat_json_interface structured_data

and added following 2 lines

ckanext.dcat.enable_rdf_endpoints = False
ckanext.dcat.catalog_endpoint = /dcat/catalog/{_format}

Now when i go to dataset page, i am gettig error - "Internal server error"

In the console, i get following error

2022-08-16 19:56:20,313 ERROR [ckan.config.middleware.flask_app] Could not build url for endpoint 'dcat.read_catalog' with values ['_format']. Did you mean 'dataset.read' instead?
Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/../../views/dataset.py", line 376, in search
    _get_pkg_template(u'search_template', package_type), extra_vars
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
    return flask_render_template(template_name, **extra_vars)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 140, in render_template
    ctx.app,
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/templating.py", line 120, in _render
    rv = template.render(context)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/ckan/default/src/ckanext-dcat/ckanext/dcat/plugins/../templates/package/search.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/search.html", line 2, in top-level template code
    {% import 'macros/form.html' as form %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/usr/lib/ckan/default/src/ckanext-harvest/ckanext/harvest/plugin/../templates/base.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/default/ckanext-visualize/ckanext/visualize/templates/base.html", line 1, in top-level template code
    <!--
  File "/usr/lib/ckan/default/src/ckanext-scheming/ckanext/scheming/templates/base.html", line 1, in top-level template code
    {% ckan_extends %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/base.html", line 52, in top-level template code
    {% block links -%}
  File "/usr/lib/ckan/default/src/ckanext-dcat/ckanext/dcat/plugins/../templates/package/search.html", line 5, in block "links"
    <link rel="alternate" type="text/n3" href="{{ h.url_for(endpoint, _format='n3', _external=True) }}"/>
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 353, in url_for
    my_url = _url_for_flask(*args, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 415, in _url_for_flask
    my_url = _flask_default_url_for(*args, **kw)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/helpers.py", line 370, in url_for
    return appctx.app.handle_url_build_error(error, endpoint, values)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/app.py", line 2215, in handle_url_build_error
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/flask/helpers.py", line 358, in url_for
    endpoint, values, method=method, force_external=external
  File "/usr/lib/ckan/default/lib/python3.6/site-packages/werkzeug/routing.py", line 2179, in build
    raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'dcat.read_catalog' with values ['_format']. Did you mean 'dataset.read' instead?
@filos1983
Copy link

Hello @student2017USA, I've the same issue. Have you found a solution? I cannot figure what's going wrong

Thanks!

@seitenbau-govdata
Copy link
Member

when i go to dataset page

@student2017USA What exactly do you mean with that? Can you provide an example URL?
Does it work with the following setting
ckanext.dcat.enable_rdf_endpoints = True

@seitenbau-govdata
Copy link
Member

Hello @student2017USA, I've the same issue. Have you found a solution? I cannot figure what's going wrong

Thanks!

Hi @filos1983 Can you provide some more information about what you have tried?

@filos1983
Copy link

filos1983 commented Oct 4, 2023

Hello @seitenbau-govdata, thanks for your help. I'm trying to install DCAT extension in CKAN 2.9 but, as Student2017Usa described in his post, the Dataset page gave me "Internal server error" when I add dcat dcat_json_harvester dcat_json_interface structured_data in ckan.plugins.
In logs the error message was

File "/usr/lib/ckan/default/lib/python3.6/site-packages/werkzeug/routing.py", line 2179, in build
  raise BuildError(endpoint, values, method, self)
werkzeug.routing.BuildError: Could not build url for endpoint 'dcat.read_catalog' with values ['_format']. Did you mean 'dataset.read' instead?

According with your suggestion, I've inserted the line

ckanext.dcat.enable_rdf_endpoints = True

in my ckan.ini file and now it works.

Thank you very much

amercader added a commit that referenced this issue Oct 4, 2023
Fixes #230

The templates were always trying to create the endpoints URL, even if
the routes were not registered in the blueprint because it was set to
ckanext.dcat.enable_rdf_endpoints = False
@amercader
Copy link
Member

amercader commented Oct 4, 2023

The problem is that the plugin tries to create the URL for the endpoints in the templates even if the routes are not registered in the blueprint (because ckanext.dcat.enable_rdf_endpoints = False). I've created #259 to fix this

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 a pull request may close this issue.

4 participants