yikart/AiToEarn · error · KwaiPlatformException

15070

15070

Error message

{{platform}} platform API request failed

What it means

KwaiService's axios interceptor converts every failed Kwai Open API request into a KwaiPlatformException with ResponseCode.ChannelPlatformApiFailed (15070). Unlike the other services here, this interceptor also checks successful responses for a Kwai business-error payload (hasPlatformError) and throws fromPlatformResponse, but the HTTP-error branch wraps every AxiosError (network failure or non-2xx response) with fromAxiosError. The exception carries endpoint, method, HTTP status, Kwai error code/message, and retryability.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/kwai/kwai.service.ts:41

@Injectable()
export class KwaiService {
  private readonly http: AxiosInstance

  constructor(private readonly cfg: KwaiConfig) {
    this.http = this.createHttpClient()
  }

  private createHttpClient(): AxiosInstance {
    const http = axios.create()
    http.interceptors.response.use(
      (response) => {
        if (KwaiPlatformException.hasPlatformError(response)) {
          throw KwaiPlatformException.fromPlatformResponse(response)
        }
        return response
      },
      (error: AxiosError<KwaiPlatformResponseBody>) => {
        throw KwaiPlatformException.fromAxiosError(error)
      },
    )
    return http
  }

  private async request<T>(
    url: string,
    config: AxiosRequestConfig = {},
  ): Promise<KwaiApiResponse<T>> {
    const response = await this.http.request<KwaiApiResponse<T>>({
      ...config,
      method: config.method ?? 'GET',
      url,
    })
    return response.data
  }

  generateAuthUrl(

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Read the thrown KwaiPlatformException's cause (platformCode/platformMessage/httpStatus) to identify Kwai's exact error code and meaning.
  2. If the platform code indicates token expiry, refresh the Kwai access token and retry the request.
  3. If retryable is true (network error or 5xx), retry with backoff.
  4. For publishing errors, validate the video URL/duration/format against Kwai's publishing requirements before retrying.
  5. Check that the Kwai app credentials and callback domain match the open-platform console configuration, and verify network reachability to Kwai API hosts.

Example fix

// before: expired token -> Kwai business error wrapped as 15070
const res = await this.http.post(`${this.apiBaseUrl}/openapi/photo/upload`, formData, { headers })

// after: handle token expiry explicitly
try {
  const res = await this.http.post(`${this.apiBaseUrl}/openapi/photo/upload`, formData, { headers })
} catch (e) {
  if (e instanceof KwaiPlatformException && e.cause?.platformCode === KwaiErrorCode.TokenExpired) {
    const fresh = await this.refreshAccessToken(channel)
    // retry with fresh token
  } else throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: credentials configured and token valid before calling Kwai Open API
if (!cfg.appId || !cfg.appSecret) throw new Error('Kwai app credentials missing')
if (!accessToken || tokenExpiresAt <= new Date()) await refreshKwaiToken(channel)

Type guard

function isKwaiPlatformException(e: unknown): e is KwaiPlatformException {
  return e instanceof KwaiPlatformException
}

Try / catch

try {
  const result = await kwaiService.publishVideo(accessToken, payload)
} catch (e) {
  if (e instanceof KwaiPlatformException) {
    if (e.cause?.platformCode === KwaiErrorCode.TokenExpired) {
      // refresh token and retry once
    } else if (e.retryable) {
      // exponential backoff retry
    } else {
      // inspect cause.platformCode against Kwai docs; surface to channel owner
    }
  } else throw e
}

Prevention

When it happens

Trigger: Any request through this.http / this.request — OAuth token exchange, publishing videos, fetching account info against Kwai Open API — that fails at the network level or returns a non-2xx HTTP response; also Kwai responses whose body carries a business error even with HTTP 200 (caught by the success-branch check).

Common situations: Kwai access/refresh token expired; appid/appsecret misconfigured for the Kwai open platform app; publishing outside permitted quota or content policy rejection returned as a platform error code; Kwai API downtime (5xx); server unable to reach Kwai endpoints due to egress/firewall rules.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/67fccafbbd252a71. Report an issue: GitHub.