data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

[Bug]: `DAB_ENVIRONMENT` env var set with `folder/dab-config.json` is processed incorrectly

Open seantleonard opened this issue 1 year ago • 3 comments

What happened?

A bug happened!

FileSystemRuntimeConfigLoader::GetFileName(string? environmentValue, bool considerOverrides) does not generate a correct file name/path when the input arg environmentValue is something like folder/dab-config.json

Here are the var values as shown in the debugger: image

Version

1.2

What database are you using?

Azure SQL

What hosting model are you using?

Local (including CLI)

Which API approach are you accessing DAB through?

No response

Relevant log output

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

seantleonard avatar Sep 11 '24 17:09 seantleonard

I don't see this as a bug. The ENV variable is supposed to contain the Environment name such as Development, Prod, etc. Providing a file path is incorrect and should be treated as a user error.

We can improve our doc to be more specific like:

### ENV Variable

The `ENV` variable is used to determine the environment-specific configuration file. The file name is constructed as `abc.{ENV}.json`.

### Expected Values

The `ENV` variable should contain only valid environment names. Examples of valid environment names include:

- `prod`
- `dev`
- `staging`
- `prod1`

### Validation Rules

1. The `ENV` variable must only contain alphanumeric characters and dots (`.`).
2. The `ENV` variable must not include the file extension (e.g., `.json`).

### Examples

#### Valid Values

- `ENV=prod` results in `abc.prod.json`
- `ENV=dev` results in `abc.dev.json`
- `ENV=staging` results in `abc.staging.json`

abhishekkumams avatar Sep 12 '24 07:09 abhishekkumams

What scenario would ever create this json.json part though?

image

JerryNixon avatar Sep 23 '24 19:09 JerryNixon

What scenario would ever create this json.json part though?

image

if DAB_ENV = Config/dab-config-bigdog.json it will lead to the corresponding scenario.

abhishekkumams avatar Sep 30 '24 08:09 abhishekkumams