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

Reflect the service nullability behavior of Error and endTime #10262

Conversation

christothes
Copy link
Member

MSFT employees can try out our new experience at OpenAPI Hub - one location for using our validation tools and finding your workflow.

Contribution checklist:

Please follow the link to find more details on PR review process.

@openapi-pipeline-app
Copy link

openapi-pipeline-app bot commented Jul 27, 2020

[Staging] Swagger Validation Report

️✔️BreakingChange [Detail]
 There are no breaking changes. 
LintDiff: 2 Errors, 0 Warnings [Detail] [Expand]
Rule Message
An error occurred while executing JSON.parse() on the linter output for specification/keyvault/data-plane/readme.md: "role":"Lint Diff",
"new":"https://github.com/Azure/azure-rest-api-specs/blob/625a4165f8a2ee84549f61e46620e1442a509ab5/specification/keyvault/data-plane/readme.md",
"old":"https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/readme.md"
An error occurred while executing JSON.parse() on the linter output for specification/keyvault/data-plane/readme.md: "role":"Lint Diff",
"new":"https://github.com/Azure/azure-rest-api-specs/blob/625a4165f8a2ee84549f61e46620e1442a509ab5/specification/keyvault/data-plane/readme.md",
"old":"https://github.com/Azure/azure-rest-api-specs/blob/master/specification/keyvault/data-plane/readme.md"
️✔️Avocado [Detail]
 Validation passes for Avocado. 
Posted by Swagger Pipeline | How to fix these errors?

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@christothes christothes changed the title Reflect nullability of Error and endTime Reflect the service nullability behavior of Error and endTime Jul 27, 2020
@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

Azure CLI Extension Generation - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

azure-sdk-for-go - Release

failed [Logs] [Expand Details]
  • Generate from 625a416 with merge commit edecc35. SDK Automation 13.0.17.20200807.2
    [AutoRest] FATAL: System.InvalidOperationException: Swagger document contains two or more x-ms-enum extensions with the same name 'JsonWebKeyType' and different values: EC,EC-HSM,RSA,RSA-HSM,oct,oct-HSM vs. RSA,RSA-HSM
    [AutoRest]    at AutoRest.Modeler.ObjectBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\ObjectBuilder.cs:line 147
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.ParentBuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 204
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 46
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 131
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 131
    [AutoRest]    at AutoRest.Modeler.ObjectBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\ObjectBuilder.cs:line 179
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.ParentBuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 204
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 46
    [AutoRest]    at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 131
    [AutoRest]    at AutoRest.Modeler.SwaggerModeler.BuildCompositeTypes() in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SwaggerModeler.cs:line 271
    [AutoRest]    at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SwaggerModeler.cs:line 66
    [AutoRest]    at AutoRest.Modeler.Program.d__2.MoveNext() in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\Program.cs:line 60
    [AutoRest] --- End of stack trace from previous location where exception was thrown ---
    [AutoRest]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    [AutoRest]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    [AutoRest]    at NewPlugin.d__15.MoveNext()
    [AutoRest] FATAL: go/imodeler1 - FAILED
    [AutoRest] FATAL: Error: Plugin imodeler1 reported failure.
    [AutoRest] Failure during batch task - {"tag":"package-7.2-preview"} -- Error: Plugin imodeler1 reported failure..
    [AutoRest]   Error: Plugin imodeler1 reported failure.
    Failed to run autorest.
    Error: /z/node_modules/.bin/autorest [email protected]/autorest.go@~2.1.153 --go --verbose --multiapi --use-onever --preview-chk --version=V2 --go-sdk-folder=/z/work/src/github.com/Azure/azure-sdk-for-go /z/work/azure-rest-api-specs/specification/keyvault/data-plane/readme.md FATAL: System.InvalidOperationException: Swagger document contains two or more x-ms-enum extensions with the same name 'JsonWebKeyType' and different values: EC,EC-HSM,RSA,RSA-HSM,oct,oct-HSM vs. RSA,RSA-HSM
       at AutoRest.Modeler.ObjectBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\ObjectBuilder.cs:line 147
       at AutoRest.Modeler.SchemaBuilder.ParentBuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 204
       at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 46
       at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 131
       at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 131
       at AutoRest.Modeler.ObjectBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\ObjectBuilder.cs:line 179
       at AutoRest.Modeler.SchemaBuilder.ParentBuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 204
       at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 46
       at AutoRest.Modeler.SchemaBuilder.BuildServiceType(String serviceTypeName, Boolean required) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SchemaBuilder.cs:line 131
       at AutoRest.Modeler.SwaggerModeler.BuildCompositeTypes() in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SwaggerModeler.cs:line 271
       at AutoRest.Modeler.SwaggerModeler.Build(ServiceDefinition serviceDefinition) in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\SwaggerModeler.cs:line 66
       at AutoRest.Modeler.Program.d__2.MoveNext() in C:\Users\ci\AppData\Local\Temp\PUBLISH8kiit\38_20171116T010915\autorest.modeler\src\Program.cs:line 60
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at NewPlugin.d__15.MoveNext()
    FATAL: go/imodeler1 - FAILED
    FATAL: Error: Plugin imodeler1 reported failure.
    Failure during batch task - {"tag":"package-7.2-preview"} -- Error: Plugin imodeler1 reported failure..
      Error: Plugin imodeler1 reported failure.
    , {} 
    Failed to find any diff after autorest so no changed packages was found.

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

azure-sdk-for-java - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

azure-sdk-for-js - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

azure-sdk-for-net - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

azure-sdk-for-python - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Jul 27, 2020

Trenton Generation - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@azuresdkci
Copy link
Contributor

Can one of the admins verify this patch?

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'd rather the service team sign-off on the changes.

@@ -67,7 +67,8 @@
"$ref": "#/definitions/Error"
}
},
"description": "The key vault server error."
"description": "The key vault server error.",
"x-nullable": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johanste is this correct? I thought x-nullable would be applied where this type is returned.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the service actually return null here? If so, why? The property is optional. And we really don't want to have semantically meaningful null values for content-type application/json payloads.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing the service returns null for properties of the Error model, including innererror, which is of type Error.

"innererror": {
"x-ms-client-name": "innerError",
"readOnly": true,
"$ref": "#/definitions/Error"
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the intention is to indicate that fields of the Error type can be null then you want to apply x-nullable to the applicable fields (like you did in backuprestore.json).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error value itself is returned as null. I think the service should clarify which of the types and properties are expected to be nullable before finalizing on the correct swagger change.

Currently, marking just the Error properties results in a null ref exception in generated code, but marking the whole Error type does not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check with @pakrym - or even just try it with local swaggers - if setting x-nullable: true on the model itself even works as intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes to both :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed HSM usage of Error is that when there is no error in a correct case we are returning null to indicate the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The service should not return a null value on the wire. You should omit the key/value pair altogether. Is there a reason that the service is sending null on the wire?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In speaking with @vasanthrajams previously, this is consistent with existing Key Vault api behavior, so changing it now could be breaking.

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to keep unblocked since I'm going OOF soon, but please make sure that marking a model as nullable even works as intended. It's ideal if it does since any operation can return it, so hopefully you don't have to mark all refs as nullable.

@mayurid mayurid merged commit edecc35 into Azure:master Aug 24, 2020
@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Aug 24, 2020

azure-resource-manager-schemas - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

@openapi-sdkautomation
Copy link

openapi-sdkautomation bot commented Aug 24, 2020

azure-sdk-for-python-track2 - Release

No readme.md specification configuration files were found that are associated with the files modified in this pull request, or swagger_to_sdk section in readme.md is not configured

maorleger added a commit to Azure/azure-sdk-for-js that referenced this pull request Apr 21, 2021
This PR includes regenerated code from the stable 7.2 swagger. Up until now it was in preview, but now that it's 
stable we're regenerating (and expected no meaningful changes).

But there were meaningful changes! Recently our code generator started emitting `null` based on the x-nullable spec
which unfortunately expanded CertificateOperation.error and ErrorModel.innerError to be `ErrorModel | undefined | **null**`
Since this data is going from server to client we can only narrow it, we can't expand it without a breaking change. This is 
made worse because we re-exported ErrorModel as-is in 4.1. 

I looked into it and realized that this is done for historical reasons and not semantically meaningful 
see: Azure/azure-rest-api-specs#10262 (comment).

So I am deprecating `ErrorModel` since we should use the `CertificateOperationError` type anyway, ensuring that the 
existing ErrorModel does not change, and applying the transformation from null to undefined in the convenience layer to 
keep the API the same.
jay-most pushed a commit to jay-most/azure-sdk-for-js that referenced this pull request Apr 26, 2021
This PR includes regenerated code from the stable 7.2 swagger. Up until now it was in preview, but now that it's 
stable we're regenerating (and expected no meaningful changes).

But there were meaningful changes! Recently our code generator started emitting `null` based on the x-nullable spec
which unfortunately expanded CertificateOperation.error and ErrorModel.innerError to be `ErrorModel | undefined | **null**`
Since this data is going from server to client we can only narrow it, we can't expand it without a breaking change. This is 
made worse because we re-exported ErrorModel as-is in 4.1. 

I looked into it and realized that this is done for historical reasons and not semantically meaningful 
see: Azure/azure-rest-api-specs#10262 (comment).

So I am deprecating `ErrorModel` since we should use the `CertificateOperationError` type anyway, ensuring that the 
existing ErrorModel does not change, and applying the transformation from null to undefined in the convenience layer to 
keep the API the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants