{"record":{"id":"6539f64048505363","repo":"facebook/relay","slug":"relay-environment-configuration-error-dev-only","errorCode":null,"errorMessage":"Relay Environment Configuration Error (dev only): `@required(action: LOG)` requires that the Relay Environment be configured with a `relayFieldLogger`.","messagePattern":"Relay Environment Configuration Error \\(dev only\\): `@required\\(action: LOG\\)` requires that the Relay Environment be configured with a `relayFieldLogger`\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/relay-runtime/store/defaultRelayFieldLogger.js","lineNumber":18,"sourceCode":"/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @flow strict-local\n * @format\n * @oncall relay\n */\n\n'use strict';\n\nimport type {RelayFieldLogger} from './RelayStoreTypes';\n\nconst defaultRelayFieldLogger: RelayFieldLogger = event => {\n  if (__DEV__ && event.kind === 'missing_required_field.log') {\n    throw new Error(\n      'Relay Environment Configuration Error (dev only): `@required(action: LOG)` requires that the Relay Environment be configured with a `relayFieldLogger`.',\n    );\n  }\n};\n\nmodule.exports = defaultRelayFieldLogger;\n","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/packages/relay-runtime/store/defaultRelayFieldLogger.js#L1-L25","documentation":"@required(action: LOG) fields report missing-field events through the environment's relayFieldLogger. The default logger deliberately throws in __DEV__ when such an event arrives, telling the developer the environment was never configured with a real logger; in production it silently no-ops.","triggerScenarios":"Reading a snapshot where a @required(action: LOG) field is missing while the Environment was created without passing relayFieldLogger to the constructor (and the app is running in development).","commonSituations":"Creating a new Environment in tests or Storybook with only a network/store and forgetting relayFieldLogger; adding @required(action: LOG) to a fragment without updating environment setup; dev-only builds surfacing what production hides.","solutions":["Pass relayFieldLogger to the Relay Environment constructor with a handler for missing_required_field.log events","Import and wire defaultRelayFieldLogger replacement, e.g. from relay-runtime/store/RelayDefaultFieldLogger (or your own)","If the throw is intentional dev noise, confirm __DEV__ flag and add the logger before data reads","Remove or downgrade @required(action: LOG) if logging isn't actually wanted"],"exampleFix":"// before\nconst env = new Environment({network, store});\n// after\nconst env = new Environment({network, store, relayFieldLogger: myFieldLogger});","handlingStrategy":"validation","validationCode":"if (__DEV__ && env.getNetwork == null) {/*...*/}\n// Before reading data in dev, assert the environment was built with a field logger:\nconsole.assert(envConfig.relayFieldLogger != null, 'Configure relayFieldLogger for @required(action: LOG)');","typeGuard":"null","tryCatchPattern":"try {\n  lookupData();\n} catch (e) {\n  if (String(e.message).includes('relayFieldLogger')) {\n    console.error('Environment missing relayFieldLogger; configure it for @required(action: LOG)');\n  } else throw e;\n}","preventionTips":["Always pass relayFieldLogger when constructing Environment objects, including tests/Storybook","Centralize Environment creation in one factory","Grep for @required(action: LOG) when adding new environments","Keep dev and prod environment setups in sync"],"tags":["relay","environment","configuration","dev-only","required-field"],"backgroundTag":"missing-env-var","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}