oracle / oracle/oci-python-sdk

Can not parse request

Open
#787 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

SDK
Dominant language
Python
Stars
474
Forks
321
Avg merge
23m
Merged PRs (30d)
4

Description

import oci

config = oci.config.from_file()
compute_client = oci.core.ComputeClient(config)

compartment_id = "ocid1.compartment.oc1..xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

launch_details = oci.core.models.LaunchInstanceDetails(
    availability_domain="EU-FRANKFURT-1-AD-3",
    compartment_id=compartment_id,
    shape="VM.Standard.A1.Flex",
    display_name="Server",
    source_details=oci.core.models.InstanceSourceViaImageDetails(
        source_type="image",
        image_id="ocid1.image.oc1.eu-frankfurt-1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    ),
    create_vnic_details=oci.core.models.CreateVnicDetails(
        subnet_id="ocid1.subnet.oc1.eu-frankfurt-1.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        assign_public_ip=True,
        assign_private_dns_record=True
    ),
    shape_config=oci.core.models.LaunchInstanceShapeConfigDetails(
        memory_in_gbs=24,
        ocpus=4
    ),
    metadata={
        "ssh_authorized_keys": open(r"/path/to/ssh-key.pub").read().strip()
    },
    agent_config=oci.core.models.LaunchInstanceAgentConfigDetails(
        is_management_disabled=False,
        is_monitoring_disabled=False,
        plugins_config=[
            {"name": "Vulnerability Scanning", "desired_state": "DISABLED"},
            {"name": "Management Agent", "desired_state": "DISABLED"},
            {"name": "Custom Logs Monitoring", "desired_state": "ENABLED"},
            {"name": "Compute RDMA GPU Monitoring", "desired_state": "DISABLED"},
            {"name": "Compute Instance Monitoring", "desired_state": "ENABLED"},
            {"name": "Compute HPC RDMA Auto-Configuration", "desired_state": "DISABLED"},
            {"name": "Compute HPC RDMA Authentication", "desired_state": "DISABLED"},
            {"name": "Cloud Guard Workload Protection", "desired_state": "ENABLED"},
            {"name": "Block Volume Management", "desired_state": "DISABLED"},
            {"name": "Bastion", "desired_state": "DISABLED"}
        ]
    ),
    instance_options=oci.core.models.InstanceOptions(
        are_legacy_imds_endpoints_disabled=False
    ),
    availability_config=oci.core.models.LaunchInstanceAvailabilityConfigDetails(
        recovery_action="RESTORE_INSTANCE"
    )
)

response = compute_client.launch_instance(launch_details)
print("Launch initiated. Instance ID:", response.data.id)

oci.wait_until(
    compute_client,
    compute_client.get_instance(response.data.id),
    'lifecycle_state',
    'RUNNING',
    max_wait_seconds=600
)
print("Instance is now RUNNING")
input()
oci.exceptions.ServiceError: {
    'target_service': 'compute',
    'status': 400,
    'code': 'CannotParseRequest',
    'opc-request-id': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'message': 'Incorrectly formatted request. Please refer to our documentation for help.',
    'operation_name': 'launch_instance',
    'timestamp': '2025-08-13T15:29:34.585459+00:00',
    'client_version': 'Oracle-PythonSDK/2.157.1',
    'request_endpoint': 'POST https://iaas.eu-frankfurt-1.oraclecloud.com/20160918/instances',
    'logging_tips': 'Refer to https://docs.oracle.com/en-us/iaas/tools/python/latest/logging.html for ways to log request/response details.',
    'troubleshooting_tips': 'See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_400__400_cannotparserequest and https://docs.oracle.com/iaas/api/#/en/iaas/20160918/Instance/LaunchInstance for more info.'
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduced ComputeClient.launch_instance call and the LaunchInstanceDetails model construction, then enable SDK request logging and compare the serialized request with the linked OCI LaunchInstance API documentation. Narrow the payload to identify which field causes CannotParseRequest; done means the example launches successfully without the 400 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.