0.24 - try and create labels before use
CICD / Explore-Gitea-Actions (push) Successful in 53s Details

This commit is contained in:
Isaac Johnson 2025-10-14 11:58:30 -05:00
parent b78adf2366
commit b3548ea49d
3 changed files with 31 additions and 5 deletions

View File

@ -20,4 +20,4 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
CMD ["python", "main.py"] CMD ["python", "main.py"]
#harbor.freshbrewed.science/library/vikunjamcp:0.23 #harbor.freshbrewed.science/library/vikunjamcp:0.24

View File

@ -1,6 +1,6 @@
{ {
"name": "vikunja", "name": "vikunja",
"version": "1.0.23", "version": "1.0.24",
"mcpServers": { "mcpServers": {
"nodeServer": { "nodeServer": {
"command": "docker", "command": "docker",
@ -14,7 +14,7 @@
"VIKUNJA_USERNAME", "VIKUNJA_USERNAME",
"-e", "-e",
"VIKUNJA_PASSWORD", "VIKUNJA_PASSWORD",
"harbor.freshbrewed.science/library/vikunjamcp:0.23" "harbor.freshbrewed.science/library/vikunjamcp:0.24"
], ],
"env": { "env": {
"VIKUNJA_URL": "$VIKUNJA_URL", "VIKUNJA_URL": "$VIKUNJA_URL",

30
main.py
View File

@ -657,8 +657,34 @@ def update_task_details(
if existing_id: if existing_id:
final_labels.append({'id': existing_id}) final_labels.append({'id': existing_id})
else: else:
# Create new labels via the bulk endpoint by providing title+description # Try to create the label first via the /labels endpoint so we have a real id
final_labels.append({'title': title, 'description': title}) try:
logger.info("update_task_details: creating missing label '%s' via %s/labels", title, VIKUNJA_URL)
create_resp = session.put(f"{VIKUNJA_URL}/api/v1/labels", json={"title": title, "description": title})
# If creation failed with 4xx/5xx this will raise and be caught below
create_resp.raise_for_status()
created = create_resp.json() or {}
created_id = created.get('id')
if created_id:
title_to_id[title.lower()] = created_id
final_labels.append({'id': created_id})
logger.info("update_task_details: created label '%s' id=%s", title, created_id)
else:
# Fallback: include title/description in payload if no id returned
logger.warning("update_task_details: label created but no id returned for title='%s' - including title in bulk payload", title)
final_labels.append({'title': title, 'description': title})
except requests.exceptions.RequestException as ce:
# Creation failed; log more details and include title in payload as a fallback
resp = getattr(ce, 'response', None)
if resp is not None:
try:
logger.error("update_task_details: label creation returned status=%s body=%s for title=%s", resp.status_code, resp.text, title)
except Exception:
logger.exception("update_task_details: failed to read create label response body for title=%s", title)
else:
logger.exception("update_task_details: label creation request failed for title=%s", title)
# As a last resort try to send title in bulk payload (some servers may accept this)
final_labels.append({'title': title, 'description': title})
final_payload = {'labels': final_labels} final_payload = {'labels': final_labels}