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

[CosmosDB/DocumentDB] Accounts - Swagger/Validation Bug #1324

Closed
tombuildsstuff opened this issue Jun 19, 2017 · 4 comments
Closed

[CosmosDB/DocumentDB] Accounts - Swagger/Validation Bug #1324

tombuildsstuff opened this issue Jun 19, 2017 · 4 comments

Comments

@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Jun 19, 2017

👋

When creating a DocumentDB CosmosDB Account with the Go SDK - the maxStalenessPrefix and maxIntervalInSeconds properties are required (due to property validation) but only used when the defaultConsistencyLevel is set to BoundedStaleness.

This means when creating an Account with any other consistency level, for example Eventual, the maxIntervalInSeconds and maxStalenessPrefix fields can be set but are ignored and instead return default values:

Here's the create request:

PUT /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tharvey-dev/providers/Microsoft.DocumentDB/databaseAccounts/tharvey-cosmosdb?api-version=2015-04-08

{
	"location": "westeurope",
	"tags": {},
	"properties": {
		"consistencyPolicy": {
			"defaultConsistencyLevel": "Eventual",
			"maxStalenessPrefix": 200,
			"maxIntervalInSeconds": 10
		},
		"locations": [{
			"id": "tharvey-cosmosdb-westeurope",
			"locationName": "westeurope",
			"failoverPriority": 0
		}],
		"databaseAccountOfferType": "Standard",
		"ipRangeFilter": ""
	}
}

Which returns a 200 OK - a GET query for the Account then returns:

GET /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tharvey-dev/providers/Microsoft.DocumentDB/databaseAccounts/tharvey-cosmosdb?api-version=2015-04-08 HTTP/1.1

HTTP/1.1 200 Ok

{
	"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tharvey-dev/providers/Microsoft.DocumentDB/databaseAccounts/tharvey-cosmosdb",
	"name": "tharvey-cosmosdb",
	"location": "West Europe",
	"type": "Microsoft.DocumentDB/databaseAccounts",
	"kind": "GlobalDocumentDB",
	"tags": {},
	"properties": {
		"provisioningState": "Succeeded",
		"documentEndpoint": "https://tharvey-cosmosdb.documents.azure.com:443/",
		"ipRangeFilter": "",
		"enableAutomaticFailover": false,
		"databaseAccountOfferType": "Standard",
		"consistencyPolicy": {
			"defaultConsistencyLevel": "Eventual",
			"maxIntervalInSeconds": 5,
			"maxStalenessPrefix": 100
		},
		"configurationOverrides": {},
		"writeLocations": [{
			"id": "tharvey-cosmosdb-westeurope",
			"locationName": "West Europe",
			"documentEndpoint": "https://tharvey-cosmosdb-westeurope.documents.azure.com:443/",
			"provisioningState": "Succeeded",
			"failoverPriority": 0
		}],
		"readLocations": [{
			"id": "tharvey-cosmosdb-westeurope",
			"locationName": "West Europe",
			"documentEndpoint": "https://tharvey-cosmosdb-westeurope.documents.azure.com:443/",
			"provisioningState": "Succeeded",
			"failoverPriority": 0
		}],
		"failoverPolicies": [{
			"id": "tharvey-cosmosdb-westeurope",
			"locationName": "West Europe",
			"failoverPriority": 0
		}]
	}
}

Unfortunately the validation on these fields means these fields have to be specified (as such we can't just not set them and read the default value).

Would it be possible to investigate updating the validation to allow these fields to be optional?

Thanks!

@tombuildsstuff
Copy link
Contributor Author

@marstr @mcardosos I'm assuming this is Swagger related, and not SDK/Generator related?

@marstr
Copy link
Member

marstr commented Jun 19, 2017

Looking at the swagger here, it seems that it's pretty clear that the validation in the Go SDK shouldn't be requiring maxStalenessPrefix or maxIntervalInSeconds at all. I'll move this issue to our repository for now.

edit: I need to figure out whether this is a problem with the generator, runtime, or SDK before I move the bug. I'll keep this one open for a bit longer.

@balajikris balajikris removed their assignment Jun 19, 2017
@tombuildsstuff
Copy link
Contributor Author

Awesome, thanks @marstr :)

@marstr
Copy link
Member

marstr commented Jun 19, 2017

Closing in favor of the issue above

@marstr marstr closed this as completed Jun 19, 2017
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

No branches or pull requests

3 participants