Primary finding
postprocess-admanage-create: ad sets with only campaignId (no parentCampaignConfigName) are not written to state
- scripts/postprocess-admanage-create.sh:121-123
- scripts/postprocess-admanage-create.sh:126-143
- scripts/postprocess-admanage-create.sh:166-171
The script allows an ad-set payload to include a direct campaignId without a parentCampaignConfigName. In that case, parent_name is empty and the state update selects no campaign (select(.configName == $parent)), so the created ad set is never appended to .admanage-state/campaigns.json. This contradicts the stated purpose of appending new ad-set IDs and can lead to duplicate provisioning on subsequent runs because state does not reflect reality.
Recommendation
When parentCampaignConfigName is absent, derive the parent for state updates by: (a) reverse-mapping campaignId to configName from STATE_FILE (build an ID->configName map alongside NAME_TO_ID), or (b) store ad sets under the campaignId key in state when configName is unavailable. Alternatively, require parentCampaignConfigName for all ad-set payloads and skip with an explicit error if missing.