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

AssemblyInfo.bytes_expected can be null #26

Closed
andreyvit opened this issue Nov 15, 2019 · 18 comments
Closed

AssemblyInfo.bytes_expected can be null #26

andreyvit opened this issue Nov 15, 2019 · 18 comments
Assignees
Labels
sdks Integrations for Transloadit's API

Comments

@andreyvit
Copy link

Hey!

WaitAssembly fails for me with the following error: failed unmarshal http request: json: cannot unmarshal string into Go struct field AssemblyInfo.bytes_expected of type int

The corresponding assembly response is below. You can clearly see that bytes_expected is null.

{
    "ok": "ASSEMBLY_COMPLETED",
    "http_code": 200,
    "message": "The Assembly was successfully completed.",
    "assembly_id": "10182eee988945da98a455cc1e3d1319",
    "parent_id": null,
    "account_id": "***REDACTED***",
    "template_id": "229a0e60629241e3848af05038322ee6",
    "instance": "rang.transloadit.com",
    "assembly_url": "http://api2.rang.transloadit.com/assemblies/10182eee988945da98a455cc1e3d1319",
    "assembly_ssl_url": "https://api2-rang.transloadit.com/assemblies/10182eee988945da98a455cc1e3d1319",
    "uppyserver_url": "https://api2-rang.transloadit.com/companion/",
    "companion_url": "https://api2-rang.transloadit.com/companion/",
    "websocket_url": "https://api2-rang.transloadit.com/ws20034",
    "tus_url": "https://api2-rang.transloadit.com/resumable/files/",
    "bytes_received": 118604,
    "bytes_expected": null,
    "upload_duration": 0.886,
    "client_agent": null,
    "client_ip": null,
    "client_referer": null,
    "transloadit_client": "go-sdk:v1.1.1",
    "start_date": "2019/11/15 13:51:53 GMT",
    "upload_meta_data_extracted": true,
    "warnings": [],
    "is_infinite": false,
    "has_dupe_jobs": false,
    "execution_start": "2019/11/15 13:51:54 GMT",
    "execution_duration": 1.727,
    "queue_duration": 0.317,
    "jobs_queue_duration": 0.01,
    "notify_start": null,
    "notify_url": null,
    "notify_status": null,
    "notify_response_code": null,
    "notify_duration": null,
    "last_job_completed": "2019/11/15 13:51:56 GMT",
    "fields": {},
    "running_jobs": [],
    "bytes_usage": 763547,
    "executing_jobs": [],
    "started_jobs": [
        ":original:::original",
        "original:::original",
        "resize_full1080::original",
        "resize_thumb360::original",
        "export::original",
        "thumb360::resize_thumb360",
        "full1080::resize_full1080",
        "export::thumb360",
        "export::full1080"
    ],
    "parent_assembly_status": null,
    "params": "{\"auth\":{\"key\":\"****\",\"expires\":\"2019/11/15 14:51:53+00:00\"},\"template_id\":\"229a0e60629241e3848af05038322ee6\"}",
    "template": "{\"steps\":{\":original\":{\"robot\":\"/upload/handle\"},\"original\":{\"use\":\":original\",\"robot\":\"/file/filter\",\"accepts\":[[\"${file.mime}\",\"regex\",\"image\"]],\"error_on_decline\":true},\"resize_full1080\":{\"use\":\"original\",\"robot\":\"/image/resize\",\"resize_strategy\":\"min_fit\",\"format\":\"jpg\",\"quality\":90,\"width\":1080,\"height\":1080,\"strip\":true,\"zoom\":true,\"background\":\"#ffffff\",\"rotation\":true,\"imagemagick_stack\":\"v2.0.7\"},\"resize_thumb360\":{\"use\":\"original\",\"robot\":\"/image/resize\",\"resize_strategy\":\"min_fit\",\"format\":\"jpg\",\"quality\":90,\"width\":360,\"height\":360,\"strip\":true,\"zoom\":true,\"background\":\"#ffffff\",\"rotation\":true,\"imagemagick_stack\":\"v2.0.7\"},\"full1080\":{\"robot\":\"/image/optimize\",\"use\":\"resize_full1080\",\"priority\":\"compression-ratio\"},\"thumb360\":{\"robot\":\"/image/optimize\",\"use\":\"resize_thumb360\",\"priority\":\"compression-ratio\"},\"export\":{\"use\":[\"original\",\"full1080\",\"thumb360\"],\"robot\":\"/s3/store\",\"credentials\":\"s3_user_content\",\"path\":\"${previous_step.name}/${file.original_id}_${previous_step.name}.${file.ext}\",\"acl\":\"private\"}}}",
    "merged_params": "{\"steps\":{\":original\":{\"robot\":\"/upload/handle\"},\"original\":{\"use\":\":original\",\"robot\":\"/file/filter\",\"accepts\":[[\"${file.mime}\",\"regex\",\"image\"]],\"error_on_decline\":true},\"resize_full1080\":{\"use\":\"original\",\"robot\":\"/image/resize\",\"resize_strategy\":\"min_fit\",\"format\":\"jpg\",\"quality\":90,\"width\":1080,\"height\":1080,\"strip\":true,\"zoom\":true,\"background\":\"#ffffff\",\"rotation\":true,\"imagemagick_stack\":\"v2.0.7\"},\"resize_thumb360\":{\"use\":\"original\",\"robot\":\"/image/resize\",\"resize_strategy\":\"min_fit\",\"format\":\"jpg\",\"quality\":90,\"width\":360,\"height\":360,\"strip\":true,\"zoom\":true,\"background\":\"#ffffff\",\"rotation\":true,\"imagemagick_stack\":\"v2.0.7\"},\"full1080\":{\"robot\":\"/image/optimize\",\"use\":\"resize_full1080\",\"priority\":\"compression-ratio\"},\"thumb360\":{\"robot\":\"/image/optimize\",\"use\":\"resize_thumb360\",\"priority\":\"compression-ratio\"},\"export\":{\"use\":[\"original\",\"full1080\",\"thumb360\"],\"robot\":\"/s3/store\",\"credentials\":\"s3_user_content\",\"path\":\"${previous_step.name}/${file.original_id}_${previous_step.name}.${file.ext}\",\"acl\":\"private\"}},\"allow_steps_override\":true,\"auth\":{\"key\":\"****\",\"expires\":\"2019/11/15 14:51:53+00:00\"},\"template_id\":\"229a0e60629241e3848af05038322ee6\"}",
    "uploads": [
        {
            "id": "dece9a004dda4a3ebbeb65eada3ddadf",
            "name": "xxx.jpg",
            "basename": "xxx",
            "ext": "jpg",
            "size": 117953,
            "mime": "image/jpeg",
            "type": "image",
            "field": "asset",
            "md5hash": "fdc26c4c343d129b8568f8f1c45a16d2",
            "original_id": "dece9a004dda4a3ebbeb65eada3ddadf",
            "original_basename": "xxx",
            "original_name": "xxx.jpg",
            "original_path": "/",
            "original_md5hash": "fdc26c4c343d129b8568f8f1c45a16d2",
            "from_batch_import": false,
            "is_tus_file": false,
            "tus_upload_url": null,
            "url": "http://tmp-eu-west-1.transloadit.com.s3-eu-west-1.amazonaws.com/dece9a004dda4a3ebbeb65eada3ddadf.jpg",
            "ssl_url": "https://s3-eu-west-1.amazonaws.com/tmp-eu-west-1.transloadit.com/dece9a004dda4a3ebbeb65eada3ddadf.jpg",
            "meta": {
                "width": 341,
                "height": 341,
                "date_recorded": null,
                "date_file_created": null,
                "date_file_modified": "2019/11/15 13:51:54 GMT",
                "title": null,
                "description": null,
                "duration": null,
                "location": null,
                "aspect_ratio": "1.000",
                "city": null,
                "state": null,
                "country": null,
                "country_code": null,
                "keywords": null,
                "aperture": null,
                "exposure_compensation": null,
                "exposure_mode": null,
                "exposure_time": null,
                "flash": null,
                "focal_length": null,
                "f_number": null,
                "iso": null,
                "light_value": null,
                "metering_mode": null,
                "shutter_speed": null,
                "white_balance": null,
                "device_name": null,
                "device_vendor": null,
                "device_software": "Picasa",
                "latitude": null,
                "longitude": null,
                "orientation": "Horizontal (normal)",
                "has_clipping_path": false,
                "creator": null,
                "author": null,
                "copyright": null,
                "copyright_notice": null,
                "frame_count": 1,
                "colorspace": "RGB",
                "has_transparency": false,
                "dominant_colors": null,
                "average_color": "#886a54",
                "xp_title": null,
                "xp_comment": null,
                "xp_keywords": null,
                "xp_subject": null
            }
        }
    ],
    "results": {
        "original": [
            {
                "id": "dece9a004dda4a3ebbeb65eada3ddadf",
                "name": "xxx.jpg",
                "basename": "xxx",
                "ext": "jpg",
                "size": 117953,
                "mime": "image/jpeg",
                "type": "image",
                "field": "asset",
                "md5hash": "fdc26c4c343d129b8568f8f1c45a16d2",
                "original_id": "dece9a004dda4a3ebbeb65eada3ddadf",
                "original_basename": "xxx",
                "original_name": "xxx.jpg",
                "original_path": "/",
                "original_md5hash": "fdc26c4c343d129b8568f8f1c45a16d2",
                "from_batch_import": false,
                "is_tus_file": false,
                "tus_upload_url": null,
                "url": "***REDACTED***",
                "ssl_url": "***REDACTED***",
                "meta": {
                    "width": 341,
                    "height": 341,
                    "date_file_modified": "2019/11/15 13:51:54 GMT",
                    "aspect_ratio": "1.000",
                    "device_software": "Picasa",
                    "orientation": "Horizontal (normal)",
                    "has_clipping_path": false,
                    "frame_count": 1,
                    "colorspace": "RGB",
                    "has_transparency": false,
                    "average_color": "#886a54"
                },
                "cost": 23591,
                "queue": "live",
                "queueTime": 0,
                "execTime": 0.58
            }
        ],
        "thumb360": [
            {
                "id": "17c477802c884ea39b768ce873443125",
                "name": "xxx.jpg",
                "basename": "xxx",
                "ext": "jpg",
                "size": 17366,
                "mime": "image/jpeg",
                "type": "image",
                "field": "asset",
                "md5hash": "04185b2e84f28e56c30318a6143dc2e7",
                "original_id": "dece9a004dda4a3ebbeb65eada3ddadf",
                "original_basename": "xxx",
                "original_name": "xxx.jpg",
                "original_path": "/",
                "original_md5hash": "fdc26c4c343d129b8568f8f1c45a16d2",
                "from_batch_import": false,
                "is_tus_file": false,
                "tus_upload_url": null,
                "url": "http***REDACTED***",
                "ssl_url": "***REDACTED***",
                "meta": {
                    "width": 360,
                    "height": 360,
                    "date_file_modified": "2019/11/15 13:51:54 GMT",
                    "aspect_ratio": "1.000",
                    "has_clipping_path": false,
                    "frame_count": 1,
                    "colorspace": "sRGB",
                    "has_transparency": false,
                    "average_color": "#886a54"
                },
                "cost": 55424,
                "queue": "live",
                "queueTime": 0,
                "execTime": 0.43
            }
        ],
        "full1080": [
            {
                "id": "165b7965da2c4751a38d5a1c38b21b82",
                "name": "xxx.jpg",
                "basename": "xxx",
                "ext": "jpg",
                "size": 77887,
                "mime": "image/jpeg",
                "type": "image",
                "field": "asset",
                "md5hash": "f754a69ad50523e674a484a8c0bdcfee",
                "original_id": "dece9a004dda4a3ebbeb65eada3ddadf",
                "original_basename": "xxx",
                "original_name": "xxx.jpg",
                "original_path": "/",
                "original_md5hash": "fdc26c4c343d129b8568f8f1c45a16d2",
                "from_batch_import": false,
                "is_tus_file": false,
                "tus_upload_url": null,
                "url": "***REDACTED***",
                "ssl_url": "***REDACTED***",
                "meta": {
                    "width": 1080,
                    "height": 1080,
                    "date_file_modified": "2019/11/15 13:51:55 GMT",
                    "aspect_ratio": "1.000",
                    "has_clipping_path": false,
                    "frame_count": 1,
                    "colorspace": "sRGB",
                    "has_transparency": false,
                    "average_color": "#886954"
                },
                "cost": 250125,
                "queue": "live",
                "queueTime": 0.01,
                "execTime": 0.55
            }
        ]
    },
    "build_id": "300"
}

The code producing the error is really nothing special:

	assembly := transloadit.NewAssembly()
	assembly.TemplateID = "229a0e60629241e3848af05038322ee6"

	data, err := ioutil.ReadAll(body)
	if err != nil {
		return nil, err
	}

	err = ioutil.WriteFile("/tmp/upload.jpg", data, 0644)
	if err != nil {
		panic(err)
	}
	log.Printf("assets: upload saved as /tmp/upload.jpg")

	assembly.AddReader("asset", "xxx.jpg", ioutil.NopCloser(bytes.NewReader(data)))
	log.Printf("assets: uploading...")
	info, err := as.trans.StartAssembly(ctx, assembly)
	if err != nil {
		log.Printf("WARNING: assets: uploading failed: %+v", err)
		return nil, err
	}

	log.Printf("assets: uploading complete")
	spew.Dump(info)

	log.Printf("assets: checking %v", info.AssemblySSLURL)

	info, err = as.trans.WaitForAssembly(ctx, info)
	if err != nil {
		log.Printf("WARNING: assets: processing failed: %+v", err)
		return nil, err
	}

	log.Printf("assets: processing complete")
	spew.Dump(info)

and it fails at WaitForAssembly call.

Note: I think I've redacted all private data. The image itself isn't private, just my userpic.

@kvz
Copy link
Member

kvz commented Nov 15, 2019

/cc @ifedapoolarewaju @Acconut

@Acconut
Copy link
Member

Acconut commented Nov 15, 2019

Thanks for the detailed report, @andreyvit! This is not really a bug in the Go SDK but Transloadit's API is returning unexpected data. The bytes_expected should not be null, especially for non-tus uploads. I will see if we can fix this root cause. /cc @tim-kos

@tim-kos
Copy link
Member

tim-kos commented Nov 18, 2019

Added to my todo.

@D-sense
Copy link

D-sense commented Jan 5, 2020

Hi. Please has there been a fix to this issue. I am experiencing the exact problem right now. Trying something like "info.Results["resize"][0].SSLURL" after a call to WaitForAssembly() the exact error message.

@Acconut
Copy link
Member

Acconut commented Jan 5, 2020

@D-sense What exact values in the expression info.Results["resize"][0].SSLURL is nil? Even after waiting for an Assembly to complete, you must manually ensure that the Assembly did produce results. info.Results["resize"] may be an empty array if the "resize" step did not output any files (maybe because it had no input files).

If the problem persists, please open a new issue as this seems unrelated or contact us at support@transloadit.com

@D-sense
Copy link

D-sense commented Jan 6, 2020

@Acconut ,
Yes, I am doing this:

if info.Results["resize"][0] != nil  {
  finalUrl = info.Results["resize"][0].SSLURL
  fmt.Printf("You can view the result at: %s\n", finalUrl)
  //return finalUrl, nil
}

I still get the same error result. I have also tried polling on my end (by wrapping the login inside a for loop.)

@Acconut
Copy link
Member

Acconut commented Jan 6, 2020

@D-sense You code looks incorrect. You must check the array length before accessing its items. Something like:

if len(info.Results["resize"]) > 0  {
  finalUrl = info.Results["resize"][0].SSLURL
  fmt.Printf("You can view the result at: %s\n", finalUrl)
  //return finalUrl, nil
}

@D-sense
Copy link

D-sense commented Jan 6, 2020

@Acconut,
I got the same error result even using the logic you provided above. It's obvious that the WaitForAssembly() isn't returning data. I need the url of a location the file was uploaded to.

@Acconut
Copy link
Member

Acconut commented Jan 7, 2020

@D-sense Please open a new issue or contact us at support@transloadit.com and include the code for reproduction.

@lekevbot lekevbot added the sdks Integrations for Transloadit's API label Feb 8, 2021
@SaschaPWittwer
Copy link

Is there an ETA of this issue being fixed? I have the exact same behavior as @andreyvit.
When calling WaitForAssembly it sometimes (randomly) fails with the error failed unmarshal http request: json: cannot unmarshal string into Go struct field AssemblyInfo.bytes_expected of type int.

Just to be clear, I am using the sdk via its intended API and no custom or special way.

@Acconut
Copy link
Member

Acconut commented Aug 10, 2021

@SaschaPWittwer Thank you for the report! We haven´t had a customer mentioning this in the last months, but now we will start investigation again. Could you share a bit more details on your setup and details? i.e. how many files are you upload, what is their size? Is this happening repeatedly or just during some periods? Is your network condition reliable or rather inconsistent? Does WaitForAssembly return the error directly after starting or just after a few seconds? Any information would help!

@SaschaPWittwer
Copy link

@Acconut Thanks for the reply!
We have our own little go application which receives the images from the web client and then passes them to transloadit.
The amount of files is between 1 to 10 as I tested it and the file size reaches up to 4MB. Our network conditions are perfectly fine, never had any issues in that regard so I think this shouldn't be it.
The error is returned instantly and if we retry the exact same file it sometimes works afterwards or sometimes takes like 3-4 tries.

I know that those information's aren't as detailed as you might have hoped, but it is as it is. We tested our own application quit some time to analyze the error but could find any real indicator on why the error appears.

@Acconut
Copy link
Member

Acconut commented Dec 13, 2021

@tim-kos In the CI tests, I noticed that this error resurfaced in another fashion:

failed unmarshal http request: json: cannot unmarshal string into Go struct field AssemblyInfo.bytes_expected of type int

This means that the bytes_expected property in the API response is a string, and therefore the JSON parser cannot, by default, convert it into an integer.

Here is an example response I captured, showing what the assembly response looked like:

{
   "ok":"ASSEMBLY_UPLOADING",
   "http_code":200,
   "message":"The Assembly is still in the process of being uploaded.",
   "assembly_id":"ee98ab33118849d1992d3b057c4515f1",
   "parent_id":null,
   "account_id":"***",
   "account_name":"open-test-prod",
   "account_slug":"open-test-prod",
   "template_id":null,
   "template_name":null,
   "instance":"nuenen.transloadit.com",
   "assembly_url":"http://api2.nuenen.transloadit.com/assemblies/ee98ab33118849d1992d3b057c4515f1",
   "assembly_ssl_url":"https://api2-nuenen.transloadit.com/assemblies/ee98ab33118849d1992d3b057c4515f1",
   "uppyserver_url":"https://api2-nuenen.transloadit.com/companion/",
   "companion_url":"https://api2-nuenen.transloadit.com/companion/",
   "websocket_url":"https://api2-nuenen.transloadit.com/ws20159",
   "tus_url":"https://api2-nuenen.transloadit.com/resumable/files/",
   "bytes_received":16314,
   "bytes_expected":"", // <---------- Should be a number, not a string
   "upload_duration":0.035,
   "client_agent":null,
   "client_ip":null,
   "client_referer":null,
   "transloadit_client":"go-sdk:v1.3.0",
   "start_date":"2021/12/13 10:56:09 GMT",
   "upload_meta_data_extracted":false,
   "warnings":[
      
   ],
   "is_infinite":false,
   "has_dupe_jobs":false,
   "execution_start":null,
   "execution_duration":null,
   "queue_duration":0.002,
   "jobs_queue_duration":0,
   "notify_start":null,
   "notify_url":"https://example.com/",
   "notify_status":null,
   "notify_response_code":null,
   "notify_duration":null,
   "last_job_completed":null,
   "fields":{
      
   },
   "running_jobs":[
      
   ],
   "bytes_usage":0,
   "executing_jobs":[
      
   ],
   "started_jobs":[
      
   ],
   "parent_assembly_status":null,
   "params":"{\"auth\":{\"key\":\"****\",\"expires\":\"2021/12/13 11:56:09+00:00\"},\"notify_url\":\"https://example.com/\",\"steps\":{\"resize\":{\"background\":\"#000000\",\"height\":75,\"imagemagick_stack\":\"v2.0.7\",\"resize_strategy\":\"pad\",\"robot\":\"/image/resize\",\"width\":75}}}",
   "template":null,
   "merged_params":"{\"auth\":{\"key\":\"****\",\"expires\":\"2021/12/13 11:56:09+00:00\"},\"notify_url\":\"https://example.com/\",\"steps\":{\"resize\":{\"background\":\"#000000\",\"height\":75,\"imagemagick_stack\":\"v2.0.7\",\"resize_strategy\":\"pad\",\"robot\":\"/image/resize\",\"width\":75}}}",
   "uploads":[
      
   ],
   "results":{
      
   },
   "build_id":"1571925245"
}

Any idea, why this might happen?

@Acconut
Copy link
Member

Acconut commented Dec 13, 2021

Even more interesting: When I fetch the assembly status, now that the assembly is complete, the bytes_expected property is null (see https://api2.transloadit.com/assemblies/ee98ab33118849d1992d3b057c4515f1):

{
   "ok":"ASSEMBLY_COMPLETED",
   "http_code":200,
   "message":"The Assembly was successfully completed.",
   "assembly_id":"ee98ab33118849d1992d3b057c4515f1",
   "parent_id":null,
   "account_id":"836b8ecaed114779b02cb99d4540d81f",
   "account_name":"open-test-prod",
   "account_slug":"open-test-prod",
   "template_id":null,
   "template_name":null,
   "instance":"nuenen.transloadit.com",
   "assembly_url":"http://api2.nuenen.transloadit.com/assemblies/ee98ab33118849d1992d3b057c4515f1",
   "assembly_ssl_url":"https://api2-nuenen.transloadit.com/assemblies/ee98ab33118849d1992d3b057c4515f1",
   "uppyserver_url":"https://api2-nuenen.transloadit.com/companion/",
   "companion_url":"https://api2-nuenen.transloadit.com/companion/",
   "websocket_url":"https://api2-nuenen.transloadit.com/ws20159",
   "tus_url":"https://api2-nuenen.transloadit.com/resumable/files/",
   "bytes_received":16314,
   "bytes_expected":null,
   "upload_duration":0.487,
   "client_agent":null,
   "client_ip":null,
   "client_referer":null,
   "transloadit_client":"go-sdk:v1.3.0",
   "start_date":"2021/12/13 10:56:09 GMT",

@Acconut
Copy link
Member

Acconut commented Dec 13, 2021

I remember that the CI tests are try to replay an Assembly. Could the incorrect values be caused by replaying an Assembly?

@Acconut
Copy link
Member

Acconut commented Dec 14, 2021

Could the incorrect values be caused by replaying an Assembly?

Doesn't seems like it. I disabled the test on the CI for replaying assemblies and the error is still occurring.

@fi0
Copy link

fi0 commented Dec 23, 2021

I'm getting this error as well.

@Acconut
Copy link
Member

Acconut commented Dec 30, 2021

We haven't been able to find the root cause for why bytes_expected is a string in rare situations, so we implemented a workaround in 6ba2d3a and b95d703 and released in v1.4.1. This should help with this problem a lot. Let us know if this problem occurs again.

@Acconut Acconut closed this as completed Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdks Integrations for Transloadit's API
Projects
None yet
Development

No branches or pull requests

8 participants