/check_mk/api/1.0/domain-types/folder_config/collections/all throws a HTTP 500 error

Hi all,
I’m trying to access the Rest-API endpoint to show all folders: /check_mk/api/1.0/domain-types/folder_config/collections/all but I’m getting a HTTP 500 error - I’ve tried calling the link in a web browser and with curl.

Stacktrace:
// 20210406152505
// https://checkmk.contoso.com/prod/check_mk/api/1.0/domain-types/folder_config/collections/all

{
    "title": "Internal Server Error",
    "status": 500,
    "detail": "unique identifier not set",
    "crash_id": "8044a2ca-96db-11eb-b18e-00155d17cc04",
    "crash_report": {
       "href": "http://checkmk.contoso.com/prod/check_mk/crash.py?crash_id=8044a2ca-96db-11eb- b18e-00155d17cc04&site=prod",
       "method": "get",
       "rel": "cmk/crash-report",
       "type": "text/html"
     },
    "stack_trace": [
        "Traceback (most recent call last):",
        "  File \"/omd/sites/prod/lib/python3/cmk/gui/wsgi/applications/rest_api.py\", line 415, in _wsgi_app",
        "    return wsgi_app(environ, start_response)",
        "  File \"/omd/sites/prod/lib/python3/cmk/gui/wsgi/applications/rest_api.py\", line 206, in __call__",
        "    wsgi_app = self.func(ParameterDict(path_args))",
        "  File \"/omd/sites/prod/lib/python3/cmk/gui/plugins/openapi/restful_objects/decorators.py\", line 469, in _validating_wrapper",
        "    response = self.func(param)",
        "  File \"/omd/sites/prod/lib/python3/cmk/gui/plugins/openapi/endpoints/folder_config.py\", line 247, in list_folders",
        "    return constructors.serve_json(_folders_collection(folders, params['show_hosts']))",
        "  File \"/omd/sites/prod/lib/python3/cmk/gui/plugins/openapi/endpoints/folder_config.py\", line 284, in _folders_collection",
        "    'id': folder.id()",
        "  File \"/omd/sites/prod/lib/python3/cmk/gui/watolib/hosts_and_folders.py\", line 131, in id",
        "    raise Exception(\"unique identifier not set\")",
        "Exception: unique identifier not set",
        ""
    ]
}

Cheers

I tested this in one of my systems and it was working.

curl -X GET "http://localhost:8080/cmk/check_mk/api/1.0/domain-types/folder_config/collections/all" -H "accept: application/json" -H "Authorization: Basic STRING"

Response

{
  "id": "folder_config",
  "domainType": "folder_config",
  "links": [
    {
      "rel": "self",
      "href": "http://localhost:8080/cmk/check_mk/api/1.0/domain-types/folder_config/collections/all",
      "method": "GET",
      "type": "application/json",
      "domainType": "link"
    },
    {
      "rel": "self",
      "href": "http://localhost:8080/cmk/check_mk/api/1.0/domain-types/folder_config/collections/all",
      "method": "GET",
      "type": "application/json",
      "domainType": "link"
    }
  ],
  "value": [
    {
      "rel": "urn:org.restfulobjects:rels/value;collection=\"all\"",
      "href": "http://localhost:8080/cmk/check_mk/api/1.0/objects/folder_config/f33bf7de7b874f9b985744ff4caca30a",
      "method": "GET",
      "type": "application/json;profile=\"urn:org.restfulobjects:rels/object\"",
      "domainType": "link",
      "title": "Test"
    }
  ],
  "extensions": {}
}

There is only one subfolder in the main folder and this one is shown in value.

If i set a non existing parent folder i get an other error message as shown in your problem.
But i looks like your problem is also a problem with an folder id and that the systems finds a folder without id what normally not could be.

1 Like

Thank you for testing, Andreas. I updated to 2.0.0b3 yesterday, hoping for improvement. Unfortunately I am still getting the same error.
We currently have 9 folders under the main folder. If I do the following:

curl -X GET "https://checkmk.contoso.com/prod/check_mk/api/1.0/objects/folder_config/~"

I do actually get a response, although I’m not sure if it is the desired one:

// 20210420161842
// https://checkmk.contoso.com/prod/check_mk/api/1.0/objects/folder_config/~

{
  "domainType": "folder_config",
  "id": "~",
  "title": "Main directory",
  "links": [
    {
      "rel": "self",
      "href": "http://checkmk.contoso.com/prod/check_mk/api/1.0/objects/folder_config/~",
      "method": "GET",
      "type": "application/json",
      "domainType": "link"
    },
    {
      "rel": "urn:org.restfulobjects:rels/update",
      "href": "http://checkmk.contoso.com/prod/check_mk/api/1.0/objects/folder_config/~",
      "method": "PUT",
      "type": "application/json",
      "domainType": "link"
    },
    {
      "rel": "urn:org.restfulobjects:rels/delete",
      "href": "http://checkmk.contoso.com/prod/check_mk/api/1.0/objects/folder_config/~",
      "method": "DELETE",
      "type": "application/json",
      "domainType": "link"
    }
  ],
  "members": {
    
  },
  "extensions": {
    "attributes": {
      "meta_data": {
        "created_at": 1615285850.440637,
        "created_by": null,
        "updated_at": 1618863615.8612008
      },
      "site": "prod",
      "tag_agent": "cmk-agent"
    }
  }
}

Like I said, we have nine folders below the main directory. But none of them are shown…

You talk about folders without an id. Is there anyway to verify and fix this issues?

Cheers!

Here is the anonymised version of Check_MK’s crash report including Stacktrace:

Crash Report	

Exeption: 
	ValueError (unique identifier not set)

Traceback:   
	File "/omd/sites/prod/lib/python3/cmk/gui/wsgi/applications/rest_api.py", line 401, in _wsgi_app
		return wsgi_app(environ, start_response)
	File "/omd/sites/prod/lib/python3/cmk/gui/wsgi/applications/rest_api.py", line 205, in __call__
		wsgi_app = self.func(ParameterDict(path_args))
	File "/omd/sites/prod/lib/python3/cmk/gui/plugins/openapi/restful_objects/decorators.py", line 479, in _validating_wrapper
		response = self.func(param)
	File "/omd/sites/prod/lib/python3/cmk/gui/plugins/openapi/endpoints/folder_config.py", line 274, in list_folders
		return constructors.serve_json(_folders_collection(folders, params['show_hosts']))
	File "/omd/sites/prod/lib/python3/cmk/gui/plugins/openapi/endpoints/folder_config.py", line 311, in _folders_collection
		'id': folder.id()
	File "/omd/sites/prod/lib/python3/cmk/gui/watolib/hosts_and_folders.py", line 131, in id
		raise ValueError("unique identifier not set")

I hope this helps. Cheers

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact @fayepal if you think this should be re-opened.