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

[BUG] expects an integer as server response when a new aasx file is added to a file repository #220

Open
impact-merlinzerbe opened this issue Jun 13, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@impact-merlinzerbe
Copy link

impact-merlinzerbe commented Jun 13, 2024

Describe the bug

The package explorer tries to parse the response of a PostAASXPackage operation as an integer which conflicts the specification:

However the official openapi documentation specifies the reponse type of the operation as a json object of type PackageDescription (see https://app.swaggerhub.com/apis/Plattform_i40/AasxFileServerServiceSpecification/V3.0.1_SSP-001).

If such a json response is sent, the package explorer fails, trying to parse the response as an integer:

Error: Unhandled exception in AasxPackageExplorer v1.0.0.0: Input string was not in a correct format. Input string was not in a correct format. at    at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at AasxPackageLogic.PackageCentral.AasxFileServerInterface.AasxServerService.PostAASXPackage(Byte[] fileContent, String fileName, PackageContainerAasxFileRepository fileRepository) in D:\a\package-explorer\package-explorer\src\AasxPackageLogic\PackageCentral\AasxFileServerInterface\AasxServerService.cs:line 219
   at AasxPackageLogic.PackageCentral.AasxFileServerInterfaceService.PostAasxFileOnServer(String fileName, Byte[] fileContent, PackageContainerAasxFileRepository fileRepository) in D:\a\package-explorer\package-explorer\src\AasxPackageLogic\PackageCentral\AasxFileServerInterface\AasxFileServerInterfaceService.cs:line 103
   at AasxPackageLogic.PackageCentral.AasxFileServerInterface.PackageContainerAasxFileRepository.AddPackageToServer(String fileName) in D:\a\package-explorer\package-explorer\src\AasxPackageLogic\PackageCentral\AasxFileServerInterface\PackageContainerAasxFileRepository.cs:line 114
   at AasxWpfControlLibrary.PackageCentral.PackageContainerListOfListControl.CommandBinding_FileRepoAll(Control senderList, PackageContainerListBase fr, String cmd) in D:\a\package-explorer\package-explorer\src\AasxWpfControlLibrary\PackageCentral\PackageContainerListOfListControl.xaml.cs:line 329
   at AasxWpfControlLibrary.PackageCentral.PackageContainerListOfListControl.<>c__DisplayClass25_0.<<PackageContainerListControl_ButtonClick>b__0>d.MoveNext() in D:\a\package-explorer\package-explorer\src\AasxWpfControlLibrary\PackageCentral\PackageContainerListOfListControl.xaml.cs:line 466
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler).

To Reproduce

Steps to reproduce the behavior:

  1. Run this go file:

    package main
    
    import (
    	"fmt"
    	"net/http"
    )
    
    func main() {
    	http.HandleFunc("/packages", func(w http.ResponseWriter, r *http.Request) {
    		switch r.Method {
    		case http.MethodGet:
    			w.Header().Set("content-type", "application/json")
    			w.Write([]byte(`{"paging_metadata":{},"result":[]}`))
    		case http.MethodPost:
    			w.Header().Set("content-type", "application/json")
    			w.Write([]byte(`{"packageId":"my-random-id","aasIds":[]}`))
    		default:
    			w.WriteHeader(http.StatusInternalServerError)
    		}
    	})
    
    	err := http.ListenAndServe(":1234", nil)
    	if err != nil {
    		fmt.Println(err)
    	}
    }
  2. Add a new File -> AASX File Repository -> Connect HTTP/REST Repository -> "http://localhost:1234"

  3. Click vertical dots on new file repository -> Add AASX File to File Repository -> Choose any .aasx file

  4. See error in logs

Expected behavior

The package explorer should parse the response as json as defined in the official openapi documentation and not fail.

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Package Explorer Release: v2024-06-10.alpha
@impact-merlinzerbe impact-merlinzerbe added the bug Something isn't working label Jun 13, 2024
@impact-merlinzerbe impact-merlinzerbe changed the title [BUG] expects an integer as server response an aasx file is added to a file repository [BUG] expects an integer as server response when a new aasx file is added to a file repository Jun 14, 2024
@juileetikekar juileetikekar self-assigned this Jun 26, 2024
@juileetikekar
Copy link
Contributor

Hi @impact-merlinmarek,

Thank you for raising the issue !

Yes, support for only int should be changed to string in case of packageId. We will try to provide the solution as soon as possible.

@impact-merlinzerbe
Copy link
Author

Hi @juileetikekar ,

I think there is a conflict between the pdf specification and the openapi documentation:

The pdf specification contains the output parameter packageId of type string while the openapi specification defines the return type as a json object of type PackageDescription. Since the openapi specification is referenced in the pdf file, I consider both to be "the standard".

Do you have more information which of these definitions should take precedence or is this something I should raise an issue for in the specs repo?

@juileetikekar
Copy link
Contributor

Hi @impact-merlinzerbe,

Well, in general, in case of inconsistencies between the pdf and the openAPI, the issue needs to be created in the specs repo. However, the PackageDescription object consists of the PackageId as string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants