Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can not parse request

未关闭
#787 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
backend, cloud

调研方向

从已复现的 ComputeClient.launch_instance 调用和 LaunchInstanceDetails 模型构造开始,然后启用 SDK 请求日志记录,并将序列化后的请求与链接的 OCI LaunchInstance API 文档进行比较。缩小 payload 范围,以确定哪个字段导致 CannotParseRequest;完成标准是示例能够成功启动且不再出现 400 错误。

由索引模型根据 Issue 内容生成。

描述

SDK
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.'
}
主要语言
Python
星标
474
派生
321
平均合并
25 分钟
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oracle/oci-python-sdk 的其他 Issue

查看 oracle/oci-python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。