@@ -95,7 +95,7 @@ func (h *HistoryManager) ListByCollection(ctx context.Context, collectionID int6
9595 }
9696
9797 // Calculate pagination metadata
98- totalPages := int ((total + int64 (limit ) - 1 ) / int64 (limit ))
98+ totalPages := int ((total + int64 (limit ) - 1 ) / int64 (limit )) // Ceiling division
9999 currentPage := (offset / limit ) + 1
100100 hasNext := (offset + limit ) < int (total )
101101 hasPrev := offset > 0
@@ -123,9 +123,21 @@ func (h *HistoryManager) RecordExecution(ctx context.Context, data ExecutionData
123123
124124 log .Debug ("recording execution" , "method" , data .Method , "url" , data .URL , "status" , data .StatusCode )
125125
126- requestHeaders , _ := json .Marshal (data .Headers )
127- queryParams , _ := json .Marshal (data .QueryParams )
128- responseHeaders , _ := json .Marshal (data .ResponseHeaders )
126+ // Marshal to JSON for database storage
127+ requestHeaders , err := json .Marshal (data .Headers )
128+ if err != nil {
129+ return HistoryEntity {}, fmt .Errorf ("failed to marshal request headers: %w" , err )
130+ }
131+
132+ queryParams , err := json .Marshal (data .QueryParams )
133+ if err != nil {
134+ return HistoryEntity {}, fmt .Errorf ("failed to marshal query params: %w" , err )
135+ }
136+
137+ responseHeaders , err := json .Marshal (data .ResponseHeaders )
138+ if err != nil {
139+ return HistoryEntity {}, fmt .Errorf ("failed to marshal response headers: %w" , err )
140+ }
129141
130142 params := database.CreateHistoryEntryParams {
131143 CollectionID : sql.NullInt64 {Int64 : data .CollectionID , Valid : data .CollectionID > 0 },
@@ -156,14 +168,17 @@ func (h *HistoryManager) RecordExecution(ctx context.Context, data ExecutionData
156168
157169func validateExecutionData (data ExecutionData ) error {
158170 if err := crud .ValidateName (data .Method ); err != nil {
171+ log .Debug ("execution validation failed: invalid method" , "method" , data .Method )
159172 return fmt .Errorf ("invalid method: %w" , err )
160173 }
161174
162175 if err := crud .ValidateName (data .URL ); err != nil {
176+ log .Debug ("execution validation failed: invalid URL" , "url" , data .URL )
163177 return fmt .Errorf ("invalid URL: %w" , err )
164178 }
165179
166180 if data .StatusCode < 100 || data .StatusCode > 599 {
181+ log .Debug ("execution validation failed: invalid status code" , "status_code" , data .StatusCode )
167182 return fmt .Errorf ("invalid status code: %d" , data .StatusCode )
168183 }
169184
0 commit comments