code: func (c *stateClient) handleConflict(msg string, state []byte) error {
  	log.Printf("[DEBUG] Handling Atlas conflict response: %s", msg)
  
  	if c.conflictHandlingAttempted {
  		log.Printf("[DEBUG] Already attempted conflict resolution; returning conflict.")
  	} else {
  		c.conflictHandlingAttempted = true
  		log.Printf("[DEBUG] Atlas reported conflict, checking for equivalent states.")
  
  		payload, err := c.Get()
  		if err != nil {
  			return conflictHandlingError(err)
  		}
  
  		currentState, err := terraform.ReadState(bytes.NewReader(payload.Data))
  		if err != nil {
  			return conflictHandlingError(err)
  		}
  
  		proposedState, err := terraform.ReadState(bytes.NewReader(state))
  		if err != nil {
  			return conflictHandlingError(err)
  		}
  
  		if statesAreEquivalent(currentState, proposedState) {
  			log.Printf("[DEBUG] States are equivalent, incrementing serial and retrying.")
  			proposedState.Serial++
  			var buf bytes.Buffer
  			if err := terraform.WriteState(proposedState, &buf); err != nil {
  				return conflictHandlingError(err)
  
  			}
  			return c.Put(buf.Bytes())
  		} else {
  			log.Printf("[DEBUG] States are not equivalent, returning conflict.")
  		}
  	}
  
  	return fmt.Errorf(
  		"Atlas detected a remote state conflict.\n\nMessage: %s", msg)
  }
docs: // Atlas returns an HTTP 409 - Conflict if the pushed state reports the same
  // Serial number but the checksum of the raw content differs. This can
  // sometimes happen when Terraform changes state representation internally
  // between versions in a way that's semantically neutral but affects the JSON
  // output and therefore the checksum.
  //
  // Here we detect and handle this situation by ticking the serial and retrying
  // iff for the previous state and the proposed state:
  //
  //   * the serials match
  //   * the parsed states are Equal (semantically equivalent)
  //
  // In other words, in this situation Terraform can override Atlas's detected
  // conflict by asserting that the state it is pushing is indeed correct.