Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-1316

Error in the validate_doc_update function of the _users db

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 1.1
    • None
    • Database Core
    • None
    • New Contributors Level (Easy)

    Description

      Hi!

      In the validate_doc_update method of the _users database is a small error. On the one hand it seems that the `roles` attribute of the user doc is not required:

      if (newDoc.roles && !isArray(newDoc.roles)) {
      throw(

      {forbidden: 'doc.roles must be an array'}

      );
      }

      On the other hand the function iterates over the roles:

      // no system roles in users db
      for (var i = 0; i < newDoc.roles.length; i++) {
      if (newDoc.roles[i][0] === '_') {
      throw(

      { forbidden: 'No system roles (starting with underscore) in users db.' }

      );
      }
      }

      So, is the roles field required? If so, then throwing a real error would be nice since I only get a stack trace from CouchDB. If it is not required, checking it's presence before iterating over it would be necessary.

      I am kind of lost in all the new Git handling and such. Would it be appropriate to open a Github Pull Request? Or should I add a patch to this issue? Depending on the answer to the roles question I could provide a patch since it is trivial enough for me I guess

      Cheers,
      Daniel

      Attachments

        Issue Links

          Activity

            People

              fdmanana Filipe David Borba Manana
              truemped Daniel Truemper
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: