Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetBucketACL Grantee required type always nil. #916

Closed
ejcx opened this issue Oct 30, 2016 · 6 comments
Closed

GetBucketACL Grantee required type always nil. #916

ejcx opened this issue Oct 30, 2016 · 6 comments
Labels
bug This issue is a bug.

Comments

@ejcx
Copy link

ejcx commented Oct 30, 2016

While calling GetBucketAcl, the Grantee "Type" is always nil.

If you're writing a program that does a PutBucketAcl based on the GetBucketAcl results, you are consistently get API errors because PutBucketAcl Grantee requires a non-nil "Type".

I worked around this buy overwriting the Type to be "Canonical User", as per[1], but this is really non-obvious.

I'm also not sure PutBucketAcl works at all, but that's a different issue.

[1] - http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#sample-acl

@xibz
Copy link
Contributor

xibz commented Oct 31, 2016

Hello @ejcx, thank you for reaching out to us. I am unable to reproduce this.
Here is the code snippet I used,

package main                                                                                                            

import (                                                                                                                
  "fmt"                                                                                                                 

  "github.com/aws/aws-sdk-go/aws"                                                                                       
  "github.com/aws/aws-sdk-go/aws/session"                                                                               
  "github.com/aws/aws-sdk-go/service/s3"                                                                                
)                                                                                                                       

func main() {                                                                                                           
  sess := session.New()                                                                                                 
  config := &aws.Config{                                                                                                
    Region:   aws.String("us-west-2"),                                                                                  
    LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody),                                                                   
  }                                                                                                                     
  svc := s3.New(sess, config)                                                                                           
  out, err := svc.GetBucketAcl(&s3.GetBucketAclInput{                                                                   
    Bucket: aws.String("bucket"),                                                                                
  })                                                                                                                    
  fmt.Println(out, err)                                                                                                 
}  

Can you post your snippet?

@ejcx
Copy link
Author

ejcx commented Oct 31, 2016

Sure. I will post later tonight showing that type is nil.

@ejcx
Copy link
Author

ejcx commented Nov 1, 2016

Here's the code I have. I have only one grantee, and it is technically the user I am logged in as. It is always nil.

    acl, _ := svc.GetBucketAcl(&s3.GetBucketAclInput{Bucket: b.Name})

    for _, grant := range acl.Grants {
      fmt.Println(grant.Grantee.Type)
    }

@jasdel jasdel added service-api This issue is due to a problem in a service API, not the SDK implementation. guidance Question that needs advice or information. bug This issue is a bug. and removed guidance Question that needs advice or information. service-api This issue is due to a problem in a service API, not the SDK implementation. labels Nov 10, 2016
@jasdel
Copy link
Contributor

jasdel commented Nov 10, 2016

@ejcx I was able to reproduce the issue you're running into. It looks like the SDK is running into an issue parsing the isx:type XML attribute field from the response.

<AccessControlPolicy xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <Owner>
        <ID>id</ID>
        <DisplayName>name</DisplayName>
    </Owner>
    <AccessControlList>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
                <ID>id</ID>
                <DisplayName>name</DisplayName>
            </Grantee>
            <Permission>READ</Permission>
        </Grant>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
                <ID>id</ID>
                <DisplayName>name</DisplayName>
            </Grantee>
            <Permission>WRITE</Permission>
        </Grant>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
                <ID>id</ID>
                <DisplayName>name</DisplayName>
            </Grantee>
            <Permission>READ_ACP</Permission>
        </Grant>
        <Grant>
            <Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser">
                <ID>id</ID>
                <DisplayName>name</DisplayName>
            </Grantee>
            <Permission>WRITE_ACP</Permission>
        </Grant>
    </AccessControlList>
</AccessControlPolicy>

@jasdel
Copy link
Contributor

jasdel commented Nov 10, 2016

The Type field in Grantee struct has the unmarshalling metadata needed, but it looks like the REST XML unmarshaler is unable to unmarshal the field for some reason.

type Grantee struct {
    // ...

    Type *string `locationName:"xsi:type" type:"string" xmlAttribute:"true" required:"true" enum:"Type"`
}

@xibz
Copy link
Contributor

xibz commented Nov 22, 2016

Hello @ejcx, I've put together a PR, #954, that should fix this. If you have any additional feedback or questions, please reach out to us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants