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

Deserialization issue for the polymorphism support with python SDK generated in swagger PR #35589

Open
jiec-msft opened this issue May 11, 2024 · 2 comments
Assignees

Comments

@jiec-msft
Copy link

jiec-msft commented May 11, 2024

Describe the bug
Deserialization issue for the polymorphism support with python SDK generated in swagger PR.

To Reproduce
Steps to reproduce the behavior:

  1. If there swagger denotes the response with HTTP response 200 and 202, like swagger "jobs/{jobName}/start"
  2. and if the backend is not doing async and directly return the HTTP 200 with response payload.
  3. and if the response class need polymorphism support, like UserSourceInfo, and its subclasses like "BuildResultUserSourceInfo".
  4. and if in the CLI extension, we directly return the poller, like "return client.job.begin_start(resource_group, service, name, job_execution_template)"
  5. Then the CLI SDK will fail to do deserialization for the polymorphism support, like below example:
> az spring job start -n hello-world-job --debug

...
Mason try to reproduce issue in _start_initial, "pipeline_response": f<azure.core.pipeline.PipelineResponse object at 0x000001DBAE8CC790>, "cls": <function JobOperations.begin_start.<locals>.<lambda> at 0x000001DBAE89D300>, "deserialized.job_snapshot.source.type": BuildResult, "deserialized.job_snapshot.trigger_config.trigger_type": Manual
azext_spring.vendored_sdks.appplatform._serialization: Discriminator type is absent or null, use base class UserSourceInfo.
azext_spring.vendored_sdks.appplatform._serialization: Discriminator trigger_type is absent or null, use base class JobTriggerConfig.
Mason try to reproduce issue in get_long_running_output, "pipeline_response": f<azure.core.pipeline.PipelineResponse object at 0x000001DBAE8CC790>, "cls": None, "deserialized.job_snapshot.source.type": None, "deserialized.job_snapshot.trigger_config.trigger_type": None

...output

{
  "endTime": null,
  "jobSnapshot": {
    "managedComponentReferences": [],
    "provisioningState": null,
    "source": {
      "buildResultId": "/subscriptions/0753feba-86f1-4242-aff1-27938fb04531/resourceGroups/jiec-rg-target/providers/Microsoft.AppPlatform/Spring/jiec-e-df-eus-acs-gen1/buildServices/default/builds/hello-world-job/results/2",
      "type": null,
      "version": null
    },
    "template": {
      "args": null,
      "environmentVariables": [],
      "resourceRequests": {
        "cpu": "1",
        "memory": "2Gi"
      }
    },
    "triggerConfig": {
      "triggerType": null
    }
  },
  "name": "hello-world-job-0511054547125-7fc078",
  "startTime": null,
  "status": "Pending",
  "template": {
    "args": null,
    "environmentVariables": [],
    "resourceRequests": {
      "cpu": null,
      "memory": null
    }
  }
}

Expected behavior
Expect output by CLI like below in the right:
image

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

  1. The python sdk should be downloaded here: Add AppPlatform 2024-05-01-preview by haoozhang · Pull Request #28341 · Azure/azure-rest-api-specs (github.com) "azure-mgmt-appplatform-9.0.0.zip".
  2. I added some code to show above output, you can see the diff in this PR ([Don't merge] Add code to investigate the issue by jiec-msft · Pull Request #7606 · Azure/azure-cli-extensions (github.com))
  3. The full output for above CLI command with debug messages, see attched cli-debug-output.txt
  4. CLI core versions > az version
    {
    "azure-cli": "2.56.0",
    "azure-cli-core": "2.56.0",
    "azure-cli-telemetry": "1.1.0",
    "extensions": {
    "aks-preview": "0.5.137",
    "spring": "1.24.0"
    }
    }
@github-actions github-actions bot added the needs-triage This is a new issue that needs to be triaged to the appropriate team. label May 11, 2024
@xiangyan99 xiangyan99 added Autorest Issue and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 13, 2024
@iscai-msft
Copy link
Contributor

thanks for opening the issue @jiec-msft . We know what's causing this issue, it's a known bug in LRO, in case the LRO finish immediately while the return is a polymorphic type. Polymorphic deserialization pops from the resulting JSON, and if the LRO is done twice, we deserialize twice, but the second time the discriminator is not here anymore so we're not returning the polymorphic child.

Since there's a customer ticket we're going to restart our discussions on how best to solve this issue

@msyyc
Copy link
Member

msyyc commented May 13, 2024

FYI: same issue as Azure/autorest.python#2428

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants