mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-11 23:07:01 +08:00
fix: toFloat handles json.Number, CORS credentials+wildcard bug, strategy config error handling
- agent/agent.go: toFloat() now handles json.Number and int32 types to prevent silent data loss - api/server.go: CORS fix — echo specific origin instead of '*' when credentials are enabled (browsers reject Allow-Credentials with wildcard) - api/strategy.go: all 4 json.Unmarshal calls now check errors and return 'config_error' field instead of silently serving zero-value configs - store/decision.go: explicitly mark best-effort unmarshal with _ = assignment for clarity
This commit is contained in:
@@ -138,9 +138,10 @@ func (db *DecisionRecordDB) toRecord() *DecisionRecord {
|
||||
ErrorMessage: db.ErrorMessage,
|
||||
AIRequestDurationMs: db.AIRequestDurationMs,
|
||||
}
|
||||
json.Unmarshal([]byte(db.CandidateCoins), &record.CandidateCoins)
|
||||
json.Unmarshal([]byte(db.ExecutionLog), &record.ExecutionLog)
|
||||
json.Unmarshal([]byte(db.Decisions), &record.Decisions)
|
||||
// Best-effort unmarshal — empty/malformed JSON fields are left as zero values.
|
||||
_ = json.Unmarshal([]byte(db.CandidateCoins), &record.CandidateCoins)
|
||||
_ = json.Unmarshal([]byte(db.ExecutionLog), &record.ExecutionLog)
|
||||
_ = json.Unmarshal([]byte(db.Decisions), &record.Decisions)
|
||||
return record
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user