ci: fix remaining linter issues
- Fix `musttag` error by explicitly naming the unmarshaling struct types rather than using inline anonymous variables. - Fix `canonicalheader` error by capitalizing `X-Api-Key` correctly. - Run `golines` to align configuration fields correctly. Co-authored-by: TanLuong <28281768+TanLuong@users.noreply.github.com>
This commit is contained in:
parent
44e84585d6
commit
55fad303bb
2 changed files with 6 additions and 4 deletions
|
|
@ -103,9 +103,9 @@ func (p *Provider) Chat(
|
||||||
// Set headers
|
// Set headers
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
req.Header.Set(
|
req.Header.Set(
|
||||||
"X-API-Key",
|
"X-Api-Key",
|
||||||
p.apiKey,
|
p.apiKey,
|
||||||
) //nolint:canonicalheader // Anthropic API requires exact header name
|
)
|
||||||
req.Header.Set("Anthropic-Version", defaultAPIVersion)
|
req.Header.Set("Anthropic-Version", defaultAPIVersion)
|
||||||
|
|
||||||
// Execute request
|
// Execute request
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,13 @@ func (h *Handler) handleUpdateConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
// Intercept explicitly provided security tokens from JSON payload that json.Unmarshal drops.
|
// Intercept explicitly provided security tokens from JSON payload that json.Unmarshal drops.
|
||||||
// We need to decode into an anonymous struct with json tags because SecurityConfig
|
// We need to decode into an anonymous struct with json tags because SecurityConfig
|
||||||
// doesn't have json tags for its fields (it uses yaml tags).
|
// doesn't have json tags for its fields (it uses yaml tags).
|
||||||
var incomingSec struct {
|
type securityConfigPayload struct {
|
||||||
ModelList map[string]config.ModelSecurityEntry `json:"model_list"`
|
ModelList map[string]config.ModelSecurityEntry `json:"model_list"`
|
||||||
Channels *config.ChannelsSecurity `json:"channels,omitempty"`
|
Channels *config.ChannelsSecurity `json:"channels,omitempty"`
|
||||||
Web *config.WebToolsSecurity `json:"web,omitempty"`
|
Web *config.WebToolsSecurity `json:"web,omitempty"`
|
||||||
Skills *config.SkillsSecurity `json:"skills,omitempty"`
|
Skills *config.SkillsSecurity `json:"skills,omitempty"`
|
||||||
}
|
}
|
||||||
|
var incomingSec securityConfigPayload
|
||||||
if err := json.Unmarshal(body, &incomingSec); err == nil {
|
if err := json.Unmarshal(body, &incomingSec); err == nil {
|
||||||
secConfig := config.SecurityConfig{
|
secConfig := config.SecurityConfig{
|
||||||
ModelList: incomingSec.ModelList,
|
ModelList: incomingSec.ModelList,
|
||||||
|
|
@ -177,12 +178,13 @@ func (h *Handler) handlePatchConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
// Restore security fields from existing config and merge explicitly provided overrides.
|
// Restore security fields from existing config and merge explicitly provided overrides.
|
||||||
newCfg.SecurityCopyFrom(cfg)
|
newCfg.SecurityCopyFrom(cfg)
|
||||||
var patchSec struct {
|
type patchSecurityConfigPayload struct {
|
||||||
ModelList map[string]config.ModelSecurityEntry `json:"model_list"`
|
ModelList map[string]config.ModelSecurityEntry `json:"model_list"`
|
||||||
Channels *config.ChannelsSecurity `json:"channels,omitempty"`
|
Channels *config.ChannelsSecurity `json:"channels,omitempty"`
|
||||||
Web *config.WebToolsSecurity `json:"web,omitempty"`
|
Web *config.WebToolsSecurity `json:"web,omitempty"`
|
||||||
Skills *config.SkillsSecurity `json:"skills,omitempty"`
|
Skills *config.SkillsSecurity `json:"skills,omitempty"`
|
||||||
}
|
}
|
||||||
|
var patchSec patchSecurityConfigPayload
|
||||||
if err := json.Unmarshal(patchBody, &patchSec); err == nil {
|
if err := json.Unmarshal(patchBody, &patchSec); err == nil {
|
||||||
secConfig := config.SecurityConfig{
|
secConfig := config.SecurityConfig{
|
||||||
ModelList: patchSec.ModelList,
|
ModelList: patchSec.ModelList,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue