-
Notifications
You must be signed in to change notification settings - Fork 639
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
SDK UpdateChannel Call Fails to Update IVS Channel Type #2262
Comments
Hi @jaasco, Thanks for the bug report. This is related to this issue we are having with the lack of default value serialization. You can get around it with adding a middleware to manually edit the body before its signed: package main
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ivs"
"github.com/aws/aws-sdk-go-v2/service/ivs/types"
"github.com/aws/smithy-go/middleware"
smithyhttp "github.com/aws/smithy-go/transport/http"
"io"
"log"
"strings"
)
func main() {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody))
if err != nil {
log.Fatalf("unable to load SDK config, %v", err)
}
if err != nil {
fmt.Println("Error creating session:", err)
return
}
myMiddleware := middleware.SerializeMiddlewareFunc("MyTestMiddleware",
func(ctx context.Context, input middleware.SerializeInput, next middleware.SerializeHandler,
) (
output middleware.SerializeOutput, metadata middleware.Metadata, err error,
) {
req, ok := input.Request.(*smithyhttp.Request)
if !ok {
return output, metadata, fmt.Errorf("unexpected transport: %T", input.Request)
}
bodyStream := req.GetStream()
buf := new(strings.Builder)
_, err = io.Copy(buf, bodyStream)
actualBodyString := buf.String()
substring := `{"`
index := strings.Index(actualBodyString, substring)
newBodyString := actualBodyString[:index+len(substring)] + `preset":"","` + actualBodyString[len(substring)+index:]
newStream := strings.NewReader(newBodyString)
req.ContentLength = int64(len(newBodyString))
input.Request = req
input.Request, err = req.SetStream(newStream)
if err != nil {
panic(err)
}
return next.HandleSerialize(ctx, input)
})
client := ivs.NewFromConfig(cfg)
out, err := client.CreateChannel(context.TODO(), &ivs.CreateChannelInput{
Name: aws.String("foo-channel2"),
Type: types.ChannelTypeAdvancedHDChannelType,
})
if err != nil {
panic(err)
}
channelArn := out.Channel.Arn
_, err = client.UpdateChannel(context.TODO(), &ivs.UpdateChannelInput{
Arn: channelArn,
Preset: "",
Type: types.ChannelTypeStandardChannelType,
}, func(options *ivs.Options) {
options.APIOptions = append(options.APIOptions, func(stack *middleware.Stack) error {
return stack.Serialize.Add(myMiddleware, middleware.After)
})
})
if err != nil {
panic(err)
}
} At this point there is no straightforward way to fix this. Thanks, |
|
Describe the bug
When attempting to update the IVS channel's type from "Advanced HD" to "Standard" using the SDK, a ValidationException error is encountered. The SDK call seems to be not compatible with the desired preset and channel type combination.
Upon making the SDK call to change the channel type, instead of the channel type updating as expected, an error message is returned indicating a mismatch between the preset HIGHER_BANDWIDTH_DELIVERY and the desired channel type STANDARD.
Expected Behavior
The IVS channel's type should successfully update from "Advanced HD" to "Standard" without any errors. After making the SDK call, the channel type should reflect the new value "Standard" in the system.
Current Behavior
Upon attempting to update the IVS channel's type from "Advanced HD" to "Standard" using the SDK, the system returns a ValidationException error. The error message suggests a mismatch: preset: HIGHER_BANDWIDTH_DELIVERY not match channel type: STANDARD. The channel type remains unchanged post the call.
Reproduction Steps
Possible Solution
It appears the issue might stem from the fact that in Go, an empty string might not be transmitted in the HTTP request. The omitempty directive might be set in the struct tag for the related field, causing it to be omitted from the request when it's empty.
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2/service/ivs@v1.26.0 github.com/aws/aws-sdk-go-v2@v1.21.0
github.com/aws/aws-sdk-go-v2/service/ivs@v1.26.0 github.com/aws/aws-sdk-go-v2/internal/configsources@v1.1.41
github.com/aws/aws-sdk-go-v2/service/ivs@v1.26.0 github.com/aws/aws-sdk-go-v2/internal/endpoints/v2@v2.4.35
github.com/aws/aws-sdk-go-v2/service/ivs@v1.26.0 github.com/aws/smithy-go@v1.14.2
github.com/aws/aws-sdk-go-v2/service/ivs@v1.26.0 github.com/google/go-cmp@v0.5.8
Compiler and Version used
go version go1.19.3 darwin/amd64
Operating System and version
Amazon Linux
The text was updated successfully, but these errors were encountered: