Fix publish dialog sending dict instead of YAML string
The publish_tool() API expects a YAML config string, but the dialog was passing a dict directly, causing a 500 error on the server. - Update PublishWorker to accept config_yaml string and readme - Build complete tool config from Tool.to_dict() - Convert to YAML string before sending - Also include README.md if it exists in tool directory Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
deddd8efbb
commit
96f7c05744
|
|
@ -17,9 +17,10 @@ class PublishWorker(QThread):
|
||||||
success = Signal(dict)
|
success = Signal(dict)
|
||||||
error = Signal(str)
|
error = Signal(str)
|
||||||
|
|
||||||
def __init__(self, tool_data: dict):
|
def __init__(self, config_yaml: str, readme: str = ""):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.tool_data = tool_data
|
self.config_yaml = config_yaml
|
||||||
|
self.readme = readme
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
|
|
@ -27,7 +28,7 @@ class PublishWorker(QThread):
|
||||||
client = RegistryClient()
|
client = RegistryClient()
|
||||||
client.token = config.registry.token
|
client.token = config.registry.token
|
||||||
|
|
||||||
result = client.publish_tool(self.tool_data)
|
result = client.publish_tool(self.config_yaml, self.readme)
|
||||||
self.success.emit(result)
|
self.success.emit(result)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.error.emit(str(e))
|
self.error.emit(str(e))
|
||||||
|
|
@ -127,6 +128,8 @@ class PublishDialog(QDialog):
|
||||||
|
|
||||||
def _publish(self):
|
def _publish(self):
|
||||||
"""Publish the tool."""
|
"""Publish the tool."""
|
||||||
|
import yaml
|
||||||
|
|
||||||
version = self.version_input.text().strip()
|
version = self.version_input.text().strip()
|
||||||
if not version:
|
if not version:
|
||||||
QMessageBox.warning(self, "Validation", "Version is required")
|
QMessageBox.warning(self, "Validation", "Version is required")
|
||||||
|
|
@ -140,22 +143,34 @@ class PublishDialog(QDialog):
|
||||||
category = self.category_combo.currentText()
|
category = self.category_combo.currentText()
|
||||||
tags = [t.strip() for t in self.tags_input.text().split(",") if t.strip()]
|
tags = [t.strip() for t in self.tags_input.text().split(",") if t.strip()]
|
||||||
|
|
||||||
# Build tool data for publishing
|
# Build complete tool config from the Tool object
|
||||||
tool_data = {
|
tool_config = self._tool.to_dict() if hasattr(self._tool, 'to_dict') else {}
|
||||||
"name": self._tool.name,
|
|
||||||
"version": version,
|
# Update with publish dialog values
|
||||||
"description": description,
|
tool_config["name"] = self._tool.name
|
||||||
"category": category,
|
tool_config["version"] = version
|
||||||
"tags": tags,
|
tool_config["description"] = description
|
||||||
"definition": self._tool.to_dict() if hasattr(self._tool, 'to_dict') else {}
|
tool_config["category"] = category
|
||||||
}
|
if tags:
|
||||||
|
tool_config["tags"] = tags
|
||||||
|
|
||||||
|
# Convert to YAML string
|
||||||
|
config_yaml = yaml.dump(tool_config, default_flow_style=False, sort_keys=False)
|
||||||
|
|
||||||
|
# Get README if it exists
|
||||||
|
readme = ""
|
||||||
|
tool_dir = self._tool.path.parent if hasattr(self._tool, 'path') and self._tool.path else None
|
||||||
|
if tool_dir:
|
||||||
|
readme_path = tool_dir / "README.md"
|
||||||
|
if readme_path.exists():
|
||||||
|
readme = readme_path.read_text()
|
||||||
|
|
||||||
self.btn_publish.setEnabled(False)
|
self.btn_publish.setEnabled(False)
|
||||||
self.btn_cancel.setEnabled(False)
|
self.btn_cancel.setEnabled(False)
|
||||||
self.progress.show()
|
self.progress.show()
|
||||||
self.status_label.setText("Publishing...")
|
self.status_label.setText("Publishing...")
|
||||||
|
|
||||||
self._worker = PublishWorker(tool_data)
|
self._worker = PublishWorker(config_yaml, readme)
|
||||||
self._worker.success.connect(self._on_success)
|
self._worker.success.connect(self._on_success)
|
||||||
self._worker.error.connect(self._on_error)
|
self._worker.error.connect(self._on_error)
|
||||||
self._worker.start()
|
self._worker.start()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue