Cannot parse specified APT file
yogeshamrutkar opened this issue · 3 comments
I am working on Device Update for IoT. I have tried to simulator images update & package update work well. Now I am trying to package update OTA. I used below command to update the DeviceUpdateHandler.
sudo /usr/bin/AducIotAgent --extension-type updateContentHandler --extension-id 'microsoft/apt:1' --register-extension /var/lib/adu/extensions/sources/libmicrosoft_apt_1.so
When I am deploying the message, I am getting below error.
805306472(0x30000068) - ADUC_ERC_UPDATE_CONTENT_HANDLER_PARSE_BAD_FORMAT
can someone please help me to understand what I am doing wrong.
Apt-manifest file which I am using for testing.
{
"name": "Contoso-Video",
"version": "1.7.8",
"packages": [
{
"name": "aziot-identity-service"
},
{
"name": "aziot-edge"
}
],
"agentRestartRequired": false
}
Code Area (apt_parse.cpp):
std::unique_ptr AptParser::ParseAptContentFromFile(const std::string& filepath)
{
AutoFreeJsonValue_t rootValue{ json_parse_file(filepath.c_str()) };
if (!rootValue)
{
Log_Error("Failed to parse specified APT file (%s).", filepath.c_str());
throw AptParser::ParserException("Cannot parse specified APT file.");
}
return GetAptContentFromRootValue(rootValue.get());
}
Logs:
2023-04-06T08:57:53.7129Z 3438[4046] [I] Downloading full target update payload to '/var/lib/adu/downloads/d298a5a7-f216-404e-bebf-9f89e4f968cb/test-1.0.1-aziot-edge-apt-manifest.json' [Download]
2023-04-06T08:57:58.7179Z 3438[4046] [E] Failed to parse specified APT file (/var/lib/adu/downloads/d298a5a7-f216-404e-bebf-9f89e4f968cb/test-1.0.1-aziot-edge-apt-manifest.json). [ParseAptContentFromFile]
2023-04-06T08:57:58.7188Z 3438[4046] [E] An error occurred while parsing APT manifest. Cannot parse specified APT file. [ParseContent]
apt-handler.20230406-085753.log (END)
Device Information:
IoT Device – Ubuntu 18.04
Provisioning Method: Symmetric Key
DU Agent: latest
Can you please let me know what I am doing wrong.
The log has "An error occurred while parsing APT manifest. Cannot parse specified APT file."
This means the test-1.0.1-aziot-edge-apt-manifest.json JSON itself is invalid. If you open it in vscode or run it through json validator, do you see any errors?
The following shows it tracing that error:
Could you dump it in a hex editor to ensure there aren't any bad characters?
For example, here's a hexdump of the working I have below:
$ hexdump -C /mnt/c/adu/apt-manifest.json
00000000 7b 0d 0a 20 20 20 20 22 6e 61 6d 65 22 3a 20 22 |{.. "name": "|
00000010 74 65 73 74 6a 77 22 2c 0d 0a 20 20 20 20 22 76 |testjw",.. "v|
00000020 65 72 73 69 6f 6e 22 3a 20 22 31 2e 30 2e 30 2e |ersion": "1.0.0.|
00000030 30 22 2c 0d 0a 20 20 20 20 22 70 61 63 6b 61 67 |0",.. "packag|
00000040 65 73 22 3a 20 5b 0d 0a 20 20 20 20 20 20 20 20 |es": [.. |
00000050 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 22 |{.. "|
00000060 6e 61 6d 65 22 3a 20 22 62 69 73 6f 6e 2d 64 6f |name": "bison-do|
00000070 63 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 |c",.. |
00000080 20 22 76 65 72 73 69 6f 6e 22 3a 20 22 31 3a 33 | "version": "1:3|
00000090 2e 30 2e 34 2d 31 22 0d 0a 20 20 20 20 20 20 20 |.0.4-1".. |
000000a0 20 7d 0d 0a 20 20 20 20 5d 0d 0a 7d 0d 0a | }.. ]..}..|
000000ae
Once you get past the json error, you could add exact version for the elements in the "packages"
array, but technically it's optional.
For example, here is a valid apt manifest:
{
"name": "testjw",
"version": "1.0.0.0",
"packages": [
{
"name": "bison-doc",
"version": "1:3.0.4-1"
}
]
}
For more details, see: https://learn.microsoft.com/en-us/azure/iot-hub-device-update/device-update-apt-manifest#schema
@jw-msft - Thanks for your response. I can able to figure out the issue.
Problem is that inside importmanifest.json file i have specified the wrong size of apt file hence it was failling with error
'Cannot parse specified APT file.'
Inside Dicsussions section I have added two queries can you please provide your input their
- How to support certificate based authentication in Device Update Agent #454
- How to support both Image Base Update & Script Base update at the same time. #455
Thanks in advance
I commented on those discussions.
Glad you were able to figure out the issue with the file size.