oracle / oci-ruby-sdk

Ruby SDK for Oracle Cloud Infrastructure
https://cloud.oracle.com/cloud-infrastructure
Other
25 stars 22 forks source link

Requests failing when using non-ascii unicode characters in the request #48

Closed ashokkkannan closed 4 years ago

ashokkkannan commented 4 years ago

Requests failing with Authentication failure (http 401) when using non-ascii Unicode characters in the request. I tried it with few services and the behavior is the same. There seems to be some issue with the way SDK signs the requests. Note: I'm able to create the resource with name containing non-ascii Unicode characters using Console, oci-cli,oci-go-sdk just fine.

This issue combined with https://github.com/oracle/oci-ruby-sdk/issues/47 caused an outage in our production environment. I appreciate it if this issue can be prioritized.

Example:

Testing with Compute service:

Code:

def launch_instance(compute_client,
  subnet_id,
  availability_domain,
  compartment_id,
  image_id,
  shape,
  ssh_key,
  user_data)
  name = "simple-instance"
  puts "Launching instance... #{name}"
  request = OCI::Core::Models::LaunchInstanceDetails.new
  request.availability_domain = availability_domain
  request.compartment_id = compartment_id
  request.display_name = name
  request.image_id = image_id
  request.shape = shape
  request.subnet_id = subnet_id
  begin
    launch_instance_response = compute_client.launch_instance(request)
    instance = launch_instance_response.data
    puts "Launched instance '#{instance.display_name}' [#{instance.id}]"
  rescue => error
    puts "Error in creating instance #{name}; Error = #{error}"
  end  
end

Creating with normal characters (value of the name in the above code is set to "simple-instance"):

/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:20: warning: already initialized constant OCI::Identity::Models::BaseTagDefinitionValidator::VALIDATOR_TYPE_ENUM
/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:21: warning: previous definition of VALIDATOR_TYPE_ENUM was here
Launching instance... simple-instance
Launched instance 'simple-instance' [ocid1.instance.oc1.iad.anuwcljth4gjgpychc2gf43ygdpaisn7m76hq5fv6ntucfwd6noba35gapwq]

Creating with non standard characters (value of the name in the above code is set to "Futbolín"):

/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:20: warning: already initialized constant OCI::Identity::Models::BaseTagDefinitionValidator::VALIDATOR_TYPE_ENUM
/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:21: warning: previous definition of VALIDATOR_TYPE_ENUM was here
Creating Cluster - Futbolín
Error in creating cluster Futbolín; Error = { 'message': 'The required information to complete authentication was not provided or was incorrect.', 'status': 401, 'code': 'NotAuthenticated', 'opc-request-id': 'EC7E185F98AA44129DD9119A814D8E10/4169A1293DEC48BEB91FB421461D30D3/2640C1B1A4AC4372A354B33DB7A14E9E' }

Testing with OKE service:

code:

def create_cluster(ce_client, ce_client_composite, compartment_id, vcn_id, lb_subnet_ids)
  cluster_name = "Futbolín"
  puts "Creating Cluster - #{cluster_name}"
  begin
    response = ce_client.create_cluster(
      OCI::ContainerEngine::Models::CreateClusterDetails.new(
        name: cluster_name,
        compartment_id: compartment_id,
        vcn_id: vcn_id,
        kubernetes_version: KUBERNETES_VERSION,
        options: OCI::ContainerEngine::Models::ClusterCreateOptions.new(
          service_lb_subnet_ids: lb_subnet_ids
        )
      )
    )
    puts "Created Cluster response #{response.status} #{cluster_name}"
  rescue => error
    puts "Error in creating cluster #{cluster_name}; Error = #{error}"
  end  
end

Creating OKE cluster with normal character:(value of the cluster_name in the above code is set to "simple-cluster")

/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:20: warning: already initialized constant OCI::Identity::Models::BaseTagDefinitionValidator::VALIDATOR_TYPE_ENUM
/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:21: warning: previous definition of VALIDATOR_TYPE_ENUM was here
Creating Cluster - simple-cluster
Created Cluster response 202 simple-cluster

Creating OKE cluster with non-standard character:(value of the cluster_name in the above code is set to "Futbolín")

/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:20: warning: already initialized constant OCI::Identity::Models::BaseTagDefinitionValidator::VALIDATOR_TYPE_ENUM
/Library/Ruby/Gems/2.3.0/gems/oci-2.7.0/lib/oci/identity/models/base_tag_definition_validator.rb:21: warning: previous definition of VALIDATOR_TYPE_ENUM was here
Creating Cluster - Futbolín
Error in creating cluster Futbolín; Error = { 'message': 'The required information to complete authentication was not provided or was incorrect.', 'status': 401, 'code': 'NotAuthenticated', 'opc-request-id': '307A74099991423D9A16632FCE701B69/1BFE6AD2C6624C9EAD3CC80992ACE39C/9F4B1CC30D7046CD8ABAE1DAA989E099' }

Way to reproduce the issue:

Try creating a compute instance(or any oci service instance) with a name that contains non-ascii Unicode characters(example: Futbolín).

jodoglevy commented 4 years ago

Thanks for reporting this issue. If you use the web browser experience for OCI with non-ascii unicode characters, do the same operations failing here work from the browser?

ashokkkannan commented 4 years ago

Yes they work from oci web console , CLI and the go sdk (I didn't try other SDKs)

jodoglevy commented 4 years ago

Thanks, we'll take a look

ashokkkannan commented 4 years ago

Can we get some updates on this issue please? As mentioned earlier this issue combined with #47 may lead to severe issues in production. Considering the oci regions we have, it may not be long before someone else also gets impacted.

jodoglevy commented 4 years ago

Hi @ashokkkannan - we will take a look and get back to you

jyotisaini commented 4 years ago

Hi @ashokkkannan This issue has been fixed with the latest release v2.9.0.