IdentityClient.get_user() returns tenancy OCID in compartment_id field

818 views Asked by At

I have a piece of Python code like this:

  oci_config = oci.config.from_file("config_file","profile_name")
  identity = oci.identity.IdentityClient(oci_config)
  user = identity.get_user(oci_config["user"]).data

The user object returned has an attribute "compartment_id" but it has a value of tenancy OCID "ocid1.tenancy.oc1..aaaaaaaa...." which is obviously wrong. I am hoping that I can get compartment ID of user for calling other APIs. Now I have to store it configuration file instead.

My SDK version is 2.18 on Python 3.8.3.

Does any one know where to file a bug report like this? Thanks

1

There are 1 answers

2
Joe On

Compartments can be nested under other compartments, and the root compartment is the same as the tenancy. So the root compartment and the tenancy have the same ID.

If you are getting the tenancy ID back in the compartment_id field for a resource, it means the resource is in the root compartment.

You can see the same documented here. As you can see in the image at this link, the tenancy is referred to also as the "root compartment".