When trying to use either in_memory workspace or memory workspace in a Python script tool, the publishing process fails and the "ERROR 000966: The input layer is not valid" or "ERROR 999999: Something unexpected caused the tool to fail. Contact Esri" is returned
Issue has not been reproducible since ArcGIS Pro 3.0. Retesting by development in ArcGIS Pro 3.4 shows no issue in using the memory workspace when publishing web tools
解决办法
Use a scratch workspace to run and publish.
Locate the Python code in the arcgissystem\arcgisinput folder for the published service.