Skip to content
Open
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
13 changes: 12 additions & 1 deletion server/internal/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package internal

import (
"encoding/json"
"fmt"
"log"
"sort"

framework "github.com/sgnl-ai/adapter-framework"
Expand Down Expand Up @@ -87,7 +89,16 @@ func getEntityObjects(
entityObject, adapterErr = getEntityObject(reverseMapping, object)

if adapterErr != nil {
return nil, adapterErr
// Log the complete object and skip it instead of returning error
objectJSON, jsonErr := json.Marshal(object)
if jsonErr != nil {
log.Printf("[ERROR] Failed to marshal object for logging: %v. Original error: %s", jsonErr, adapterErr.Message)
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message format is inconsistent - using %v for jsonError but %s for adapterErr.Message. Both should use %v for consistency since they're both error types.

Copilot uses AI. Check for mistakes.
} else {
log.Printf("[ERROR] Skipping object due to validation error. Entity: %s, Error: %s, Object: %s",
reverseMapping.Id, adapterErr.Message, string(objectJSON))
}
Comment on lines +93 to +99
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging the complete object JSON may expose sensitive data in logs. Consider redacting or limiting the logged object content, especially if objects may contain PII or sensitive information.

Suggested change
objectJSON, jsonErr := json.Marshal(object)
if jsonErr != nil {
log.Printf("[ERROR] Failed to marshal object for logging: %v. Original error: %s", jsonErr, adapterErr.Message)
} else {
log.Printf("[ERROR] Skipping object due to validation error. Entity: %s, Error: %s, Object: %s",
reverseMapping.Id, adapterErr.Message, string(objectJSON))
}
// Avoid logging full object to prevent leaking sensitive data
log.Printf("[ERROR] Skipping object due to validation error. Entity: %s, Error: %s, ObjectType: %T",
reverseMapping.Id, adapterErr.Message, object)

Copilot uses AI. Check for mistakes.

continue // Skip this object and process the next one
}

entityObjects.Objects = append(entityObjects.Objects, entityObject)
Expand Down
13 changes: 12 additions & 1 deletion web/json_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ package web

import (
"context"
"encoding/json"
"fmt"
"log"
"strings"

"github.com/PaesslerAG/gval"
Expand Down Expand Up @@ -61,7 +63,16 @@ func convertJSONObjectList(entity *framework.EntityConfig, objects []map[string]
parsedObject, err := convertJSONObject(entity, object, opts, jsonPaths)

if err != nil {
return nil, err
// Log the complete object and skip it instead of returning error
objectJSON, jsonErr := json.Marshal(object)
if jsonErr != nil {
log.Printf("[ERROR] Failed to marshal JSON object for logging: %v. Original error: %v", jsonErr, err)
} else {
log.Printf("[ERROR] Skipping JSON object due to conversion error. Entity: %v, Error: %v, Object: %s",
entity, err, string(objectJSON))
}

continue // Skip this object and process the next one
}

if len(parsedObject) == 0 {
Expand Down
Loading