mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-28 11:50:06 +00:00
fix(api): prevent duplicate post_to_api submissions (#11836)
Some checks are pending
Create Changelog Pull Request / update-changelog-pull-request (push) Waiting to run
Close Discussion on PR Merge / close-discussion (push) Waiting to run
Frontend CI/CD / test-json-files (push) Waiting to run
Frontend CI/CD / build (push) Blocked by required conditions
Frontend CI/CD / deploy (push) Blocked by required conditions
Sync to Gitea / sync (push) Waiting to run
Some checks are pending
Create Changelog Pull Request / update-changelog-pull-request (push) Waiting to run
Close Discussion on PR Merge / close-discussion (push) Waiting to run
Frontend CI/CD / test-json-files (push) Waiting to run
Frontend CI/CD / build (push) Blocked by required conditions
Frontend CI/CD / deploy (push) Blocked by required conditions
Sync to Gitea / sync (push) Waiting to run
Add POST_TO_API_DONE idempotency guard to post_to_api() to prevent the same telemetry record from being submitted twice with the same RANDOM_UUID. This mirrors the existing POST_UPDATE_DONE pattern in post_update_to_api(). post_to_api() is called twice in build.func: - After storage validation (inside CONTAINER_STORAGE check) - After create_lxc_container() completes When both execute, the second call fails with a random_id uniqueness violation on PocketBase, generating server-side errors.
This commit is contained in:
parent
4b0e893bf1
commit
5ee4f4e34b
1 changed files with 5 additions and 0 deletions
|
|
@ -353,6 +353,9 @@ detect_ram() {
|
|||
# - Never blocks or fails script execution
|
||||
# ------------------------------------------------------------------------------
|
||||
post_to_api() {
|
||||
# Prevent duplicate submissions (post_to_api is called from multiple places)
|
||||
[[ "${POST_TO_API_DONE:-}" == "true" ]] && return 0
|
||||
|
||||
# Silent fail - telemetry should never break scripts
|
||||
command -v curl &>/dev/null || {
|
||||
[[ "${DEV_MODE:-}" == "true" ]] && echo "[DEBUG] curl not found, skipping" >&2
|
||||
|
|
@ -440,6 +443,8 @@ EOF
|
|||
-H "Content-Type: application/json" \
|
||||
-d "$JSON_PAYLOAD" &>/dev/null || true
|
||||
fi
|
||||
|
||||
POST_TO_API_DONE=true
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue