Project

Profile

Help

Issue #1125

API call to create a user includes extra `id` field

Added by amacdona@redhat.com over 5 years ago. Updated over 1 year ago.

Status:
CLOSED - WONTFIX
Priority:
Normal
Assignee:
-
Category:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:

Description

When creating a user via the API, this is an example of the json returned:

{
    "_href": "/pulp/api/v2/users/lets-go-to-joule/", 
    "_id": {
        "$oid": "559d8d9fe138237844b5646e"
    }, 
    "_ns": "users", 
    "id": "559d8d9fe138237844b5646e", 
    "login": "lets-go-to-joule", 
    "name": "lets-go-to-joule", 
    "roles": []
}

All other user endpoints serialize differently, excluding the `id` field.

{
    "_href": "/pulp/api/v2/users/lets-go-to-joule/", 
    "_id": {
        "$oid": "559d8d9fe138237844b5646e"
    }, 
    "_ns": "users", 
    "login": "lets-go-to-joule", 
    "name": "lets-go-to-joule", 
    "roles": []
}

As part of the mongoengine conversion, I have specifically added code to insert this extra field to preserve backwards compatibility. To fix (only for an X release), simply grep for a link to this issue and remove the referenced code.

History

#1 Updated by igulina@redhat.com over 5 years ago

It seems there is the same issue not only for user creation. I don't follow id and _id logic at all. Since for one things, they match, for others they differ in names and values:

1) id and _id values are duplicated for:

- binding repo
- consumer history 
- unit profiles
- repo content retrieval
- repo group publish
- event crud
- user cud - as the original issue description, but user retrieval also 
- permissions retrieval 

Check all response bodies on this pages:

https://github.com/pulp/pulp/blob/master/docs/dev-guide/integration/rest-api/consumer/bind.rst
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/history.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/profile.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/content.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/groups/publish.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/event/crud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/user/cud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/user/retrieval.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/permission/retrieval.html

2) However, id and _id values are different for:
- consumer cud and retrieval
- consumer group cud
- repo cud and retrieval
- repo group cud, retrieval and distributors
- role cud and retrieval

http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/cud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/retrieval.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/consumer/group/cud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/cud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/retrieval.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/groups/cud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/groups/retrieval.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/groups/distributors.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/role/cud.html
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/role/retrieval.html

3) the same parameter name, but different value format
Here: http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/sync.html
and for example here http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/publish.html#scheduling-a-publish
_id value is a string "_id": "52e6d29edd01fb70bd0d9c37"

but here http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/retrieval.html
it is a dictionary "_id": {"$oid": "addf9261-345e-4ce3-ad1e-436ba005287f"}

4) sometimes it's only "_id", and sometimes it's "id"
In the above example we have a parameter _id which has a value a string or a dictionary, but here http://pulp.readthedocs.org/en/latest/dev-guide/integration/events/repo-action-events.html#repository-sync-finished
we have parameter id and there is no any _id

5)
This http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/sync.html#retrieving-sync-history

doesn't include any id or _id

But all other schedules examples have _id, see the same page

6) Please notice how the variables with the same name are different in values for the first response body and for all other response bodies on this page:
http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/groups/distributors.html#list-repository-group-distributors

In the 1st sample it's:
"id": "2a146bdf-384b-4951-987e-8d42c7c4317f",
and in all other samples it's:
"id": "test_id",

7) Here http://pulp.readthedocs.org/en/latest/dev-guide/integration/nodes.html#publishing
we have "id": "nodes_http_distributor"
and on the same page in the next sample we have
"distributor_id": "nodes_http_distributor"
and for example here http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/retrieval.html#retrieve-distributors-associated-with-a-repository
we have "distributor_type_id": "harness_distributor",

8) Here http://pulp.readthedocs.org/en/latest/dev-guide/integration/nodes.html#bind
we have "repo_id": "elmer",
but here http://pulp.readthedocs.org/en/latest/dev-guide/integration/rest-api/repo/cud.html#create-a-repository
we have "id": "harness_repo_1",

9) Why we have task_id and type_id, but for example for repo cud it's simpy id, but here http://pulp.readthedocs.org/en/latest/dev-guide/integration/nodes.html#run
it's
"repo_id": "abc"

Please when/if fixing it, don't forget to update response bodies in docs.

#3 Updated by mhrivnak over 5 years ago

  • Triaged changed from No to Yes

#4 Updated by bmbouter over 1 year ago

  • Status changed from NEW to CLOSED - WONTFIX

#5 Updated by bmbouter over 1 year ago

Pulp 2 is approaching maintenance mode, and this Pulp 2 ticket is not being actively worked on. As such, it is being closed as WONTFIX. Pulp 2 is still accepting contributions though, so if you want to contribute a fix for this ticket, please reopen or comment on it. If you don't have permissions to reopen this ticket, or you want to discuss an issue, please reach out via the developer mailing list.

#6 Updated by bmbouter over 1 year ago

  • Tags Pulp 2 added

Please register to edit this issue

Also available in: Atom PDF