0.24 - try and create labels before use
CICD / Explore-Gitea-Actions (push) Successful in 53s
Details
CICD / Explore-Gitea-Actions (push) Successful in 53s
Details
This commit is contained in:
parent
b78adf2366
commit
b3548ea49d
|
@ -20,4 +20,4 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|||
COPY . .
|
||||
|
||||
CMD ["python", "main.py"]
|
||||
#harbor.freshbrewed.science/library/vikunjamcp:0.23
|
||||
#harbor.freshbrewed.science/library/vikunjamcp:0.24
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vikunja",
|
||||
"version": "1.0.23",
|
||||
"version": "1.0.24",
|
||||
"mcpServers": {
|
||||
"nodeServer": {
|
||||
"command": "docker",
|
||||
|
@ -14,7 +14,7 @@
|
|||
"VIKUNJA_USERNAME",
|
||||
"-e",
|
||||
"VIKUNJA_PASSWORD",
|
||||
"harbor.freshbrewed.science/library/vikunjamcp:0.23"
|
||||
"harbor.freshbrewed.science/library/vikunjamcp:0.24"
|
||||
],
|
||||
"env": {
|
||||
"VIKUNJA_URL": "$VIKUNJA_URL",
|
||||
|
|
28
main.py
28
main.py
|
@ -657,7 +657,33 @@ def update_task_details(
|
|||
if existing_id:
|
||||
final_labels.append({'id': existing_id})
|
||||
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
|
||||
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}
|
||||
|
|
Loading…
Reference in New Issue