Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate key with arbitrary facts #27

Open
sodacrackers opened this issue Apr 10, 2023 · 0 comments
Open

Duplicate key with arbitrary facts #27

sodacrackers opened this issue Apr 10, 2023 · 0 comments

Comments

@sodacrackers
Copy link

sodacrackers commented Apr 10, 2023

Greetings,

Can you provide advice on a duplicate key error?

We're using a custom facts gatherer to record Drupal module and related information. Ie Arbitrary Facts . However this error recently appeared.

*** Task STDERR ***
 2023/04/06 17:57:48 Clearing source: joco01

2023/04/06 17:57:53 graphql: (conn=54226, no: 1062, SQLState: 23000) Duplicate entry '390154-composer.outdated.installed.composer.installers-joco01' for key 'environment_fact_unique'

sql: insert into `environment_fact` 
(`category`, `description`, `environment`, `key_fact`, `name`, `service`, `source`, `type`, `value`) 
values 
('composer.outdated.installed', 'if-facts-gather generated Thu, 06 Apr 2023 17:57:27 +0000', 390154, false, 'composer.outdated.installed.composer.installers', DEFAULT, 'joco01', DEFAULT, 'v1.12.0')
 - parameters:{}

The fact data preparation looks like:

  /**
   * Prepare object for GraphQL.
   */
  private function dataAppend(string $name = NULL, $value = NULL, string $category = "Custom") {

    $name = preg_replace("/[^A-Za-z0-9 ]/", ".", $category . "." . $name);
    $value = is_string($value) ? $value : json_encode($value);
    $source = getenv("LAGOON_PROJECT") ?? "";
    $environment = getenv("LAGOON_ENVIRONMENT_TYPE") ?? "";

    $object = (object) [
      "name" => $name,
      "value" => substr($value, 0, 300),
      "category" => $category,
      "source" => $source,
      "environment" => $environment,
      "keyFact" => "false",
      "description" => "if-facts-gather",
    ];

    array_push($this->dataCollection, $object);

  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant