fix: InvalidClientTokenId panic + VT defaults + Dockerfile config + hardcore tests (58/61)

- Add InvalidClientTokenId, ValidationError to SqsErrors (was causing panic: WriteHeader code 0)
- Extract applyEnvironmentDefaults() with defer in LoadYamlConfig (VT=30 even without config file)
- Dockerfile: copy goaws.yaml to /conf/, pass --config flag
- Fix SendMessageBatch form parsing for AWS Query Protocol
- Add hardcore_test.sh (61 tests, 14 groups)
- Remove temp debug logs from delete_message.go
This commit is contained in:
Naeel
2026-04-09 16:11:32 +03:00
parent e5b1845acf
commit 6c1aadd886
6 changed files with 764 additions and 76 deletions
+6
View File
@@ -16,6 +16,12 @@ func init() {
"MessageTooBig": {HttpError: http.StatusBadRequest, Type: "MessageTooBig", Code: "InvalidParameterValue", Message: "The message size exceeds the limit."},
"InvalidParameterValue": {HttpError: http.StatusBadRequest, Type: "InvalidParameterValue", Code: "AWS.SimpleQueueService.InvalidParameterValue", Message: "An invalid or out-of-range value was supplied for the input parameter."},
"InvalidAttributeValue": {HttpError: http.StatusBadRequest, Type: "InvalidAttributeValue", Code: "AWS.SimpleQueueService.InvalidAttributeValue", Message: "Invalid Value for the parameter RedrivePolicy."},
// InvalidClientTokenId — невалидные credentials тенанта
"InvalidClientTokenId": {HttpError: http.StatusForbidden, Type: "InvalidClientTokenId", Code: "AWS.SimpleQueueService.InvalidClientTokenId", Message: "The security token included in the request is invalid."},
// ValidationError — ошибка валидации параметров (например, VisibilityTimeout вне диапазона)
"ValidationError": {HttpError: http.StatusBadRequest, Type: "ValidationError", Code: "AWS.SimpleQueueService.ValidationError", Message: "The input fails to satisfy the constraints specified by an AWS service."},
// LimitExceeded — превышен лимит очередей тенанта (max_queues)
"LimitExceeded": {HttpError: http.StatusBadRequest, Type: "LimitExceeded", Code: "AWS.SimpleQueueService.LimitExceeded", Message: "You've reached the limit on the number of queues."},
}
SnsErrors = map[string]SnsErrorType{
"InvalidParameterValue": {HttpError: http.StatusBadRequest, Type: "InvalidParameterValue", Code: "AWS.SimpleNotificationService.InvalidParameterValue", Message: "An invalid or out-of-range value was supplied for the input parameter."},
+19 -2
View File
@@ -230,8 +230,25 @@ type SendMessageBatchRequest struct {
}
func (r *SendMessageBatchRequest) SetAttributesFromForm(values url.Values) {
for entryIndex := range r.Entries {
r.Entries[entryIndex].MessageAttributes = parseMessageAttributes(values, fmt.Sprintf("Entries.%d.MessageAttributes", entryIndex))
// Парсим записи по AWS Query Protocol: SendMessageBatchRequestEntry.N.Id (1-based)
// Gorilla/schema с дефолтными тегами ищет Entries.0.Id, что не соответствует AWS SQS API.
for i := 1; ; i++ {
id := values.Get(fmt.Sprintf("SendMessageBatchRequestEntry.%d.Id", i))
if id == "" {
break
}
entry := SendMessageBatchRequestEntry{
Id: id,
MessageBody: values.Get(fmt.Sprintf("SendMessageBatchRequestEntry.%d.MessageBody", i)),
MessageDeduplicationId: values.Get(fmt.Sprintf("SendMessageBatchRequestEntry.%d.MessageDeduplicationId", i)),
MessageGroupId: values.Get(fmt.Sprintf("SendMessageBatchRequestEntry.%d.MessageGroupId", i)),
}
ds := values.Get(fmt.Sprintf("SendMessageBatchRequestEntry.%d.DelaySeconds", i))
if ds != "" {
entry.DelaySeconds, _ = strconv.Atoi(ds)
}
entry.MessageAttributes = parseMessageAttributes(values, fmt.Sprintf("SendMessageBatchRequestEntry.%d.MessageAttribute", i))
r.Entries = append(r.Entries, entry)
}
}