Why databag ids are that restricted?

Hello,

I’m working in a project to manage desktop computers configurations with
Chef and we are using databags to host users’ specific configurations.

At the very begining, databags seemed the correct and easy place to hold
these confs, but we found that we will have problems with users, for
example, using dots in their usernames, because databag ids do not
support this.

I’ve been hacking around Chef code trying (I haven’t been able to yet)
to make it to support it, but I wanted to know the original reason for
this restriction.

Could any Chef developer tell me why is this restriction applied exactly?

Thank you in advance.


Roberto C. Morano
Área de Proyectos

Emergya Consultoría.
Tlf: +34 954 51 75 77
Fax: +34 954 51 64 73
http://www.emergya.es

On Thursday, January 19, 2012 at 4:10 AM, Roberto C. Morano wrote:

Hello,

I'm working in a project to manage desktop computers configurations with
Chef and we are using databags to host users' specific configurations.

At the very begining, databags seemed the correct and easy place to hold
these confs, but we found that we will have problems with users, for
example, using dots in their usernames, because databag ids do not
support this.

I've been hacking around Chef code trying (I haven't been able to yet)
to make it to support it, but I wanted to know the original reason for
this restriction.

Could any Chef developer tell me why is this restriction applied exactly?

Thank you in advance.
The restrictions are there just to ensure that we don't have any gotchas when using the IDs in URLs, either with the Chef Server, or with CouchDB's HTTP API. In this case, I think everything will be fine if we relax the restriction.

The code is here:

https://github.com/opscode/chef/blob/master/chef/lib/chef/data_bag_item.rb#L41

Looking at the router code for the API server, it should support this okay:

https://github.com/opscode/chef/blob/master/chef-server-api/config/router.rb

Though I'm a bit concerned that magic content type selection could be an issue, for example if you had a data bag item with the ID "foo.xml", It's possible that your request would be interpreted as a request for an XML response. If that is the case, there's probably a workaround.

--
Dan DeLeo

--
Roberto C. Morano
Área de Proyectos

Emergya Consultoría.
Tlf: +34 954 51 75 77
Fax: +34 954 51 64 73
http://www.emergya.es

El 19/01/12 18:20, Daniel DeLeo escribió:

On Thursday, January 19, 2012 at 4:10 AM, Roberto C. Morano wrote:

Hello,

I'm working in a project to manage desktop computers configurations with
Chef and we are using databags to host users' specific configurations.

At the very begining, databags seemed the correct and easy place to hold
these confs, but we found that we will have problems with users, for
example, using dots in their usernames, because databag ids do not
support this.

I've been hacking around Chef code trying (I haven't been able to yet)
to make it to support it, but I wanted to know the original reason for
this restriction.

Could any Chef developer tell me why is this restriction applied exactly?

Thank you in advance.
The restrictions are there just to ensure that we don't have any gotchas when using the IDs in URLs, either with the Chef Server, or with CouchDB's HTTP API. In this case, I think everything will be fine if we relax the restriction.

Just what I supposed after looking into a bit hehe :]

The code is here:

https://github.com/opscode/chef/blob/master/chef/lib/chef/data_bag_item.rb#L41

Looking at the router code for the API server, it should support this okay:

https://github.com/opscode/chef/blob/master/chef-server-api/config/router.rb

Though I'm a bit concerned that magic content type selection could be an issue, for example if you had a data bag item with the ID "foo.xml", It's possible that your request would be interpreted as a request for an XML response. If that is the case, there's probably a workaround.

After hacking a while, I think that in my case it would probably be
better to use any kind of UUID instead of trying to hack chef in this way.

Many thanks for your answer Dan!

--
Dan DeLeo

--
Roberto C. Morano
Área de Proyectos

Emergya Consultoría.
Tlf: +34 954 51 75 77
Fax: +34 954 51 64 73
http://www.emergya.es