dynatrace-extensions / dynatrace-extensions-vscode

A VisualStudio Code extension to support all aspects of developing Dynatrace Extensions 2.0
Apache License 2.0
16 stars 7 forks source link

[Bug]: Error initializing workspace with existing custom extension. "Invalid CEN header" #207

Closed ItamarMM closed 6 months ago

ItamarMM commented 6 months ago

Description

I was told by the Dynatrace Support to open an issue here.

I am having trouble initializing a workspace with an already created 2.0 extension by one of your assessors. Using the latest schema foundable in our dynatrace tenant, I am able to download other extensions, but NOT custom ones. I need to be able to edit these working custom extensions.

Let me share with you the logs:

2024-03-20T07:49:19.380Z [DEBUG][utils.fileSystem.removeOldestFiles] Cleaning files from "c:\Users\itamar.mesa\AppData\Roaming\Code\User\globalStorage\dynatraceplatformextensions.dynatrace-extensions\logs" to keep only 10.
2024-03-20T07:49:19.407Z [INFO][extension.activate] Dynatrace Extensions version 2.4.3 is activating...
2024-03-20T07:49:19.436Z [INFO][utils.conditionCheckers.isExtensionsWorkspace] Is this an extensions workspace? false
2024-03-20T07:49:19.451Z [DEBUG][extension.activate] Instantiating feature providers
2024-03-20T07:49:19.477Z [INFO][utils.dataCaching.O0] Data Cache created.
2024-03-20T07:49:19.484Z [INFO][utils.dataCaching.O0.initialize] Initializing Data Cache...
2024-03-20T07:49:19.486Z [DEBUG][utils.dataCaching.O0.initialize] Caching built-in entity types
2024-03-20T07:49:19.500Z [DEBUG][utils.dataCaching.O0.initialize] Caching Barista icons
2024-03-20T07:49:19.510Z [DEBUG][utils.dataCaching.O0.initialize] Caching the initial extension manifest
2024-03-20T07:49:19.523Z [DEBUG][dynatrace-api.http_client.HttpClient.makeRequest] Making GET request to https://rss21366.live.dynatrace.com/api/v2/entityTypes with params {"pageSize":500} 
2024-03-20T07:49:19.734Z [INFO][utils.dataCaching.O0.initialize] Data Cache initialized.
2024-03-20T07:49:19.747Z [DEBUG][utils.simulator.loadDefaultSimulationConfig] Loaded default simulation config as {"eecType":"ONEAGENT","location":"LOCAL","sendMetrics":false}
2024-03-20T07:49:19.749Z [DEBUG][utils.fileSystem.cleanUpSimulatorLogs] Cleaning up simulator logs. Keeping only 5 files
2024-03-20T07:49:19.786Z [DEBUG][extension.activate] Subscribing feature providers to cached data
2024-03-20T07:49:19.788Z [INFO][statusBar.simulator.Bb.checkReady] Checking simulator readiness
2024-03-20T07:49:19.805Z [DEBUG][statusBar.simulator.Bb.refreshUI] Refresh UI with panel data {"dataType":"SIMULATOR_DATA","data":{"targets":[],"summaries":[],"currentConfiguration":{"eecType":"ONEAGENT","location":"LOCAL","sendMetrics":false},"specs":{"isPython":false,"dsSupportsActiveGateEec":false,"dsSupportsOneAgentEec":false,"localActiveGateDsExists":false,"localOneAgentDsExists":false},"status":"CHECKING"}}
2024-03-20T07:49:19.816Z [DEBUG][statusBar.simulator.Bb.refreshUI] Refresh UI with panel data {"dataType":"SIMULATOR_DATA","data":{"targets":[],"summaries":[],"currentConfiguration":{"eecType":"ONEAGENT","location":"LOCAL","sendMetrics":false},"specs":{"isPython":false,"dsSupportsActiveGateEec":false,"dsSupportsOneAgentEec":false,"localActiveGateDsExists":false,"localOneAgentDsExists":false},"status":"UNSUPPORTED","failedChecks":["Manifest","Datasource","Activation file"]}}
2024-03-20T07:49:19.838Z [WARN][statusBar.simulator.Bb.checkReady] Mandatory checks failed: Manifest, Datasource, Activation file
2024-03-20T07:49:19.855Z [DEBUG][extension.activate] Registering commands and feature providers
2024-03-20T07:49:19.864Z [DEBUG][extension.registerCommandPaletteCommands] Registering commands for the command palette
2024-03-20T07:49:19.874Z [DEBUG][extension.registerFeatureSwitchCommands] Registering commands for enabling/disabling features
2024-03-20T07:49:19.901Z [DEBUG][extension.registerCompletionProviders] Registering completion providers
2024-03-20T07:49:19.915Z [INFO][extension.activate] Dynatrace Extensions is now activated.
2024-03-20T07:49:20.796Z [INFO][utils.conditionCheckers.checkUrlReachable] Is URL https://rss21366.live.dynatrace.com/api/v1/time reachable? true
2024-03-20T07:49:20.837Z [INFO][utils.conditionCheckers.checkUrlReachable] Is URL https://rss21366.live.dynatrace.com/api/v1/time reachable? true
2024-03-20T07:49:20.847Z [INFO][utils.conditionCheckers.checkUrlReachable] Is URL https://rss21366.live.dynatrace.com/api/v1/time reachable? true
2024-03-20T07:49:23.401Z [INFO][utils.conditionCheckers.checkUrlReachable] Is URL https://rss21366.live.dynatrace.com/api/v1/time reachable? true
2024-03-20T07:50:28.760Z [INFO][extension] Command 'initWorkspace' called.
2024-03-20T07:50:28.764Z [INFO][utils.conditionCheckers.checkWorkspaceOpen] Is a workspace open? true
2024-03-20T07:50:28.772Z [INFO][utils.conditionCheckers.checkEnvironmentConnected] Is a tenant connected? true
2024-03-20T07:50:28.790Z [INFO][commandPalette.initWorkspace.initWorkspace] Executing Initialize Workspace command
2024-03-20T07:50:28.991Z [INFO][utils.conditionCheckers.checkUrlReachable] Is URL https://rss21366.live.dynatrace.com/api/v1/time reachable? true
2024-03-20T07:50:29.005Z [INFO][utils.conditionCheckers.checkUrlReachable] Is URL https://rss21366.live.dynatrace.com/api/v1/time reachable? true
2024-03-20T07:50:29.700Z [DEBUG][commandPalette.initWorkspace.initWorkspace] Workspace will use existing certificates
2024-03-20T07:50:29.703Z [INFO][utils.conditionCheckers.checkSettings] Settings developerCertkeyLocation exist? true
2024-03-20T07:50:29.712Z [DEBUG][commandPalette.initWorkspace.initWorkspace] InitWorkspace was given callback, executing now.
2024-03-20T07:50:29.718Z [DEBUG][commandPalette.initWorkspace.initWorkspace] Creating standard folders
2024-03-20T07:50:29.772Z [DEBUG][commandPalette.initWorkspace.initWorkspace] Prompting user for template selection
2024-03-20T07:50:30.795Z [DEBUG][commandPalette.initWorkspace.existingExtensionSetup] Setting up workspace with an existing extension
2024-03-20T07:50:30.799Z [DEBUG][dynatrace-api.http_client.HttpClient.makeRequest] Making GET request to https://rss21366.live.dynatrace.com/api/v2/extensions with params {} 
2024-03-20T07:50:32.764Z [DEBUG][commandPalette.initWorkspace.existingExtensionSetup] Attempting to download "custom:admiral.extension.sql-oracle" version 1.0.23
2024-03-20T07:50:32.768Z [DEBUG][dynatrace-api.http_client.HttpClient.makeRequest] Making GET request to https://rss21366.live.dynatrace.com/api/v2/extensions/custom:admiral.extension.sql-oracle/1.0.23 with params {} 
2024-03-20T07:50:36.907Z [INFO][extension] Command 'downloadSupportArchive' called.
2024-03-20T07:50:36.912Z [INFO][commandPalette.downloadSupportArchive] Executing Download Support Archive command

Steps to reproduce

  1. Configured VS extension Dynatrace extensions: certificates, linked to tenant correctly and so on.
  2. Tried to initialize a workspace using an already existing extension... 2.1 image 2.2 image 2.3 image 2.4 image 2.5 image

Support information

radu-stefan-dt commented 6 months ago

Thanks for raising this bug. I was able to reproduce this locally. I have a feeling this may be related to how .zip archives are created on Windows, and it would explain why all the official Dynatrace ones are fine (our pipeline packages & signs extensions on a Linux OS).

I'll have to look into this and see what solutions are there. Will be updating here and closing this issue once a fix is available.

radu-stefan-dt commented 6 months ago

Oh, actually. I have to take it back, this is not an issue with our VSCode extension, but with the Dynatrace API.

You can verify this by following the steps:

  1. Go to the Swagger API page for Environment V2 API, Extensions 2.0 endpoint
    • You can access this by replacing your tenant URL in this link: {tenant_url}/rest-api-doc/index.jsp?urls.primaryName=Environment%20API%20v2#/Extensions%202.0/extensionDetails
  2. Authenticate by passing an API token, and click "Try it out"
  3. Make a GET call to the /extensions/{extensionName}/{extensionVersion} endpoint by providing these details then clicking "Execute":
    • extensionName - set this to your extension
    • extensionVersion - set this to the version you want to download
    • Accept - set this to application/octet-stream
  4. The 200 Response will provide a clickable link to download the file.
  5. When attempting to open the .zip file the error is seen: image

I'm sorry to pass you around, but please open a Support Ticket with Dynatrace, and feel free to reference this comment for them to have a set of reproducible steps.

Here's the Swagger API page for reference: image

radu-stefan-dt commented 6 months ago

As this issue is reproducible outside of VSCode, just with the Dynatrace API alone, I will close this issue as it should be handled via Official Dynatrace Support.

radu-stefan-dt commented 6 months ago

I've reopened this issue after findings from Dynatrace Support & R&D. To summarize:

While uploading the extension ZIP file using the multipart/form-data content type, a small part of the HTTP request is added at the beginning and the end of a file.

Extensions should be uploaded using application/octet-stream content type instead.

ItamarMM commented 6 months ago

I've reopened this issue after findings from Dynatrace Support & R&D. To summarize:

While uploading the extension ZIP file using the multipart/form-data content type, a small part of the HTTP request is added at the beginning and the end of a file.

  • All extension Framework components ignore these additional parts, so the extension works.
  • Command line tools (like unzip) ignore those parts and work.
  • Windows can't handle that kind of “modified” file.

Extensions should be uploaded using application/octet-stream content type instead.

So, just to be clear, with this info I can do my job, but it really wouldn't be practical since I should still use the API manually to download the extension, modify the binary file that is in format removing the headers and footer to convert it from a multipart/form-data zip to a application/octet-stream one I guess, and then I should change the yaml in a workspace, build & upload the modified extension.

And to fix this, the problem is with the uploading part of the extension, right? So, it is a Dynatrace Extensions VS Code problem, and there is no need to contact support directly.

radu-stefan-dt commented 6 months ago

@ItamarMM - this was just a comment to re-open the issue, not an advice to use a different upload method.

Not to worry, it will be solved on our side in the VSCode extension, I aim to get it done by end of this week. No need for any additional support interaction.