Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

Integration webhooks were completely broken after upgrading to v2.16, failing with "unexpected end of JSON input" errors when processing incoming webhooks. This was caused by three issues introduced in the v2.16.2 migration that moved task_params from a JSON column to a separate table.

Root Causes

Empty params causing unmarshal errors: MapStringAnyField.Scan() attempted to unmarshal empty strings/byte slices from the database, resulting in JSON errors instead of initializing an empty map.

Nil map panic: GetTaskDefinition() created task structs without initializing the Params map, causing panics when assigning extracted webhook parameters.

Missing TaskParams in Bolt: The Bolt database implementation ignored the includeTaskParams flag and never loaded related TaskParams records, unlike the SQL implementation.

Changes

  • db/Store.go: Handle empty strings/byte slices in Scan() by initializing empty map instead of unmarshaling
  • api/integration.go: Initialize Params map before assigning extracted webhook parameters
  • db/bolt/integrations.go: Load TaskParams for integrations when requested, matching SQL behavior
  • db/Store_test.go: Add tests for empty string/byte slice scanning edge cases
// Before: panics on nil map
taskDefinition.Params[k] = v

// After: safe assignment
if taskDefinition.Params == nil {
    taskDefinition.Params = make(db.MapStringAnyField)
}
taskDefinition.Params[k] = v
Original prompt

This section details on the original issue you should resolve

<issue_title>Problem: Integrations completely broken after Upgrade to 2.16</issue_title>
<issue_description>### Issue

For my automations, I use Semaphore's ‘integrations’, i.e. incoming webhooks, a lot.
Since upgrading to 2.16, these no longer work at all, which is severely limiting my productive operations.
I also noticed in the WebGUI that the integrations there are now somewhat buggy. For example, the matchers are only displayed if you activate the slider for ‘use project alias’ in an integration.

At the same time, I also noticed that the matchers in pre-2.16 were not an AND condition, but an OR condition. Is that correct?

Impact

Web-Backend (APIs)

Installation method

Docker

Database

Postgres

Browser

Chrome

Semaphore Version

v2.16.16-4066a1e-1755362172 (PRO)
2.16.10 was the same

Ansible Version

Logs & errors

semaphore  | time="2025-08-20T13:01:14+02:00" level=info msg="Receiving Integration from: 192.168.X.X"
semaphore  | time="2025-08-20T13:01:14+02:00" level=info msg="1 integrations found for alias 0vqddzdXXXXXXX"
semaphore  | time="2025-08-20T13:01:14+02:00" level=info msg="Running integration 4"
semaphore  | time="2025-08-20T13:01:14+02:00" level=error msg="Failed to get task definition" context=integrations error="unexpected end of JSON input" integration_id=4

Manual installation - system information

No response

Configuration

No response

Additional information

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@fiftin Hi @lug-gh got it. Thank you. Will fix ASAP. @fiftin @lug-gh I'm really sorry for this. Fixed in 2.16.37 @fiftin Hi @lug-gh , @ddejan75 , @bbaassssiiee I can't reproduce the issue. I need more context.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits November 2, 2025 11:17
- Fix MapStringAnyField.Scan() to handle empty strings/bytes without error
- Initialize Params map in GetTaskDefinition when nil to prevent panic
- Load TaskParams in Bolt database for both single and project integrations
- Add comprehensive tests for MapStringAnyField scanning edge cases

Co-authored-by: fiftin <[email protected]>
Explain why empty strings/byte slices initialize empty map instead of nil

Co-authored-by: fiftin <[email protected]>
Copilot AI changed the title [WIP] Fix integrations broken after upgrade to 2.16 Fix integration webhooks failing after v2.16 upgrade with JSON unmarshal errors Nov 2, 2025
Copilot finished work on behalf of fiftin November 2, 2025 11:30
Copilot AI requested a review from fiftin November 2, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem: Integrations completely broken after Upgrade to 2.16

2 participants