Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions module/api_crud_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ func (h *RESTAPIHandler) handlePost(resourceId string, w http.ResponseWriter, r
if h.persistence != nil {
h.fieldMapping.SetValue(resource.Data, "state", resource.State)
h.fieldMapping.SetValue(resource.Data, "lastUpdate", resource.LastUpdate)
_ = h.persistence.SaveResource(h.resourceName, resource.ID, resource.Data)
if err := h.persistence.SaveResource(h.resourceName, resource.ID, resource.Data); err != nil {
h.logger.Warn(fmt.Sprintf("failed to persist resource %s/%s: %v", h.resourceName, resource.ID, err))
}
}

// If a workflow engine is configured, create an instance and trigger the initial transition
Expand Down Expand Up @@ -252,7 +254,9 @@ func (h *RESTAPIHandler) handlePut(resourceId string, w http.ResponseWriter, r *

// Write-through to persistence
if h.persistence != nil {
_ = h.persistence.SaveResource(h.resourceName, resourceId, data)
if err := h.persistence.SaveResource(h.resourceName, resourceId, data); err != nil {
h.logger.Warn(fmt.Sprintf("failed to persist resource %s/%s: %v", h.resourceName, resourceId, err))
}
}

if err := json.NewEncoder(w).Encode(h.resources[resourceId]); err != nil {
Expand Down Expand Up @@ -287,7 +291,9 @@ func (h *RESTAPIHandler) handleDelete(resourceId string, w http.ResponseWriter,

// Write-through to persistence
if h.persistence != nil {
_ = h.persistence.DeleteResource(h.resourceName, resourceId)
if err := h.persistence.DeleteResource(h.resourceName, resourceId); err != nil {
h.logger.Warn(fmt.Sprintf("failed to delete persisted resource %s/%s: %v", h.resourceName, resourceId, err))
}
}

w.WriteHeader(http.StatusNoContent)
Expand Down
3 changes: 2 additions & 1 deletion module/api_v1_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package module
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -917,7 +918,7 @@ func (h *V1APIHandler) stopWorkflow(w http.ResponseWriter, r *http.Request, id s
if inst, ok := h.runtimeManager.GetInstance(id); ok && inst.Status == "running" {
if stopErr := h.runtimeManager.StopWorkflow(r.Context(), id); stopErr != nil {
// Log but don't fail — the DB status update should still proceed
_ = stopErr
log.Printf("workflow engine: failed to stop workflow %s: %v", id, stopErr)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion module/api_workflow_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ func (h *RESTAPIHandler) syncResourceStateFromEngine(instanceId, resourceId stri

// Write-through to persistence
if h.persistence != nil {
_ = h.persistence.SaveResource(h.resourceName, res.ID, res.Data)
if err := h.persistence.SaveResource(h.resourceName, res.ID, res.Data); err != nil {
h.logger.Warn(fmt.Sprintf("failed to persist resource %s/%s: %v", h.resourceName, res.ID, err))
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions module/http_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package module

import (
"encoding/json"
"log"
"net/http"

"github.com/CrisisTextLine/modular"
Expand Down Expand Up @@ -54,8 +55,7 @@ func (h *SimpleHTTPHandler) Handle(w http.ResponseWriter, r *http.Request) {
}

if err := json.NewEncoder(w).Encode(response); err != nil {
// Log error but continue since response is already committed
_ = err
log.Printf("http handler: failed to encode response: %v", err)
}
}

Expand Down
5 changes: 2 additions & 3 deletions module/http_trigger.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package module
import (
"context"
"fmt"
"log"
"maps"
"net/http"

Expand Down Expand Up @@ -246,9 +247,7 @@ func (t *HTTPTrigger) createHandler(route HTTPTriggerRoute) HTTPHandler {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusAccepted)
if _, err := w.Write([]byte(`{"status": "workflow triggered"}`)); err != nil {
// Log error but don't fail the trigger
// Note: In a real implementation, we'd need access to a logger here
_ = err // Explicitly ignore error to satisfy linter
log.Printf("http trigger: failed to write response: %v", err)
}
}

Expand Down
10 changes: 4 additions & 6 deletions module/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -292,8 +293,7 @@ func (c *HTTPIntegrationConnector) Execute(ctx context.Context, action string, p
}
defer func() {
if err := resp.Body.Close(); err != nil {
// Log error but continue
_ = err // Explicitly ignore error to satisfy linter
log.Printf("integration: failed to close response body: %v", err)
}
}()

Expand Down Expand Up @@ -372,8 +372,7 @@ func (c *WebhookIntegrationConnector) Connect(ctx context.Context) error {
// Parse the request body
defer func() {
if err := r.Body.Close(); err != nil {
// Log error but continue
_ = err // Explicitly ignore error to satisfy linter
log.Printf("integration: failed to close request body: %v", err)
}
}()
body, err := io.ReadAll(r.Body)
Expand Down Expand Up @@ -414,8 +413,7 @@ func (c *WebhookIntegrationConnector) Connect(ctx context.Context) error {
// Return success
w.WriteHeader(http.StatusOK)
if _, err := w.Write([]byte(`{"status":"ok"}`)); err != nil {
// Log error but continue
_ = err // Explicitly ignore error to satisfy linter
log.Printf("integration: failed to write webhook response: %v", err)
}
})

Expand Down
4 changes: 3 additions & 1 deletion module/jwt_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type JWTAuthModule struct {
mu sync.RWMutex
nextID int
app modular.Application
logger modular.Logger
persistence *PersistenceStore // optional write-through backend
userStore *UserStore // optional external user store (from auth.user-store module)
}
Expand Down Expand Up @@ -89,6 +90,7 @@ func (j *JWTAuthModule) Init(app modular.Application) error {
return fmt.Errorf("JWT secret must be at least 32 bytes for security")
}
j.app = app
j.logger = app.Logger()

// Wire external user store (optional — from auth.user-store module)
for _, svc := range app.SvcRegistry() {
Expand Down Expand Up @@ -1164,7 +1166,7 @@ func (j *JWTAuthModule) Start(ctx context.Context) error {
if j.seedFile != "" {
if err := j.loadSeedUsers(j.seedFile); err != nil {
// Non-fatal: log but don't prevent startup
_ = err
j.logger.Warn("failed to load seed users", "file", j.seedFile, "error", err)
}
}

Expand Down
5 changes: 4 additions & 1 deletion scale/distributed_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/hex"
"fmt"
"hash/fnv"
"log"
"sync"
"time"

Expand Down Expand Up @@ -311,7 +312,9 @@ func (l *RedisLock) buildRelease(key, token string) func() {
return func() {
once.Do(func() {
ctx := context.Background()
_ = redisReleaseScript.Run(ctx, l.client, []string{key}, token).Err()
if err := redisReleaseScript.Run(ctx, l.client, []string{key}, token).Err(); err != nil {
log.Printf("distributed lock: failed to release Redis lock for key %s: %v", key, err)
}
})
}
}
Expand Down
Loading