1. 30 Aug, 2026 2 commits
    • fix(model): disable PostgreSQL prepared statements for pooler compatibility · 66031a09
      GORM v1.25.2 closes cached prepared statements asynchronously on any SQL
      error and immediately re-Parses the same deterministic name (pgx's
      stmt_<sha256>) on the same client connection. Transaction-pooling proxies
      (PgBouncer >=1.21 with max_prepared_statements, Neon, Supabase) respond
      with FATAL "prepared statement name is already in use" (SQLSTATE 08P01)
      and drop the connection. PreferSimpleProtocol only disables pgx's
      implicit prepare and never covered GORM's explicit PrepareStmt cache.
      
      - PostgreSQL now runs with PrepareStmt disabled entirely; named prepared
        statements are fundamentally session state and cannot be made safe
        under transaction pooling. Parse/plan cost is noise for this workload.
      - Upgrade gorm to v1.25.12 so MySQL/SQLite statement caches (still
        enabled) no longer churn close/re-prepare on ordinary SQL errors;
        v1.25.9+ restricts eviction to driver.ErrBadConn. Deliberately not
        v1.26+, whose LRU eviction has an open use-after-close race (#7831).
      - sanitizeDBError now attaches a remediation hint on 08P01/42P05 so
        affected deployments can self-diagnose from the log line.
      CaIon committed
    • feat(task): resolve channel-mapped aliases and case variants for plugin models · 6c22550e
      Channel model_mapping keys exposed in a channel's model list now act as
      first-class aliases for task-plugin models across the whole line:
      
      - Derived alias view (model/task_model_alias.go): built from enabled
        channels' model_mapping, chain-following with cycle detection, declared
        names always win, cross-plugin conflicts dropped. Rebuilt on channel
        cache refresh, registry generation change, and a 60s TTL.
      - Request path: PinTaskPluginEndpoint resolves declared-name case folds
        and mapping aliases before endpoint lookup (never rewriting the body
        until the endpoint is claimed), pins with MappedModel, and the decode
        contract accepts alias echoes without loosening model ownership for
        normal pins. Legacy /v1/tasks submit folds case variants the same way.
        Fixes aliases on POST /v1/responses silently falling through to the
        main relay against task channels.
      - Mapping order: ModelMappedHelper now runs before the plugin submit
        hook builds and caches the upstream body, so channel model_mapping
        actually reaches the upstream request. Plugins receive the mapped
        name as ctx.upstreamModel in both decode and submit contexts.
      - Billing: identity stays the origin name; when the alias has no tiered
        expression, the selected channel's mapping tail expression applies.
        Pricing page and billing-expr smoke tests resolve aliases to the
        owning plugin's usage schema.
      - Case folding: ASCII-only fold with exact-match priority; same-plugin
        and cross-plugin fold collisions rejected at registration.
      - Plugins: model-keyed rate tables, req_key derivation, and combo
        validation in doubao/kling/jimeng/hailuo/vidu/sunoapi now key on
        ctx.upstreamModel || ctx.model; render/echo paths keep ctx.model.
      CaIon committed
  2. 29 Aug, 2026 9 commits
  3. 27 Aug, 2026 3 commits
  4. 26 Aug, 2026 3 commits
  5. 21 Aug, 2026 1 commit
  6. 18 Aug, 2026 5 commits
  7. 15 Aug, 2026 5 commits
  8. 14 Aug, 2026 10 commits
  9. 13 Aug, 2026 1 commit
    • fix(billing): 异步任务退款时同步减少 used_quota (#6795) · 58d4e9bd
      * fix(billing): 异步任务退款时同步减少 used_quota
      退款时仅恢复了 quota(剩余额度),但未同步减少 used_quota(已用额度),
      导致"总额度"(quota + used_quota)随退款次数持续虚增,超出用户实际充值金额。
      
      修复三处退款路径:
      - RefundTaskQuota:任务失败完整退款
      - RecalculateTaskQuota:差额结算退款分支
      - controller/midjourney.go:Midjourney 任务失败退款
      
      新增 model.UpdateUserUsedQuota 公开函数,仅调整 used_quota 不影响 request_count。
      
      * fix(billing): 任务退款时同步扣减渠道 used_quota
      
      * fix(billing): complete async task refund accounting
      
      * style(model): group internal Midjourney fields
      
      ---------
      
      Co-authored-by: CaIon <i@caion.me>
      wans10 committed
  10. 11 Aug, 2026 1 commit