> ## Documentation Index
> Fetch the complete documentation index at: https://docs.validio.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Validio Code FAQ

> Find answers to common questions about Validio Code, including namespaces, apply behavior, and resource naming.

Find answers to common questions about using [Validio Code](https://docs.validio.io/v11.0/developer/validio-code.md), including namespaces, apply behavior, and resource naming.

## What namespace does the Validio GUI use?

Resources created in the GUI are assigned to the namespace `default`. To avoid conflicts, you should **not** use this namespace in your Validio Code (IaC) projects.

> [!NOTE]
>
> A project's namespace is displayed in the `validio.json` file in the project directory.

## Can I use Validio Code in a namespace with approval workflows enabled?

No. [Approval workflows](https://docs.validio.io/v11.0/docs/access-and-settings/approval-workflows.md) require every change in the namespace to be staged as a draft and approved by a second person, and direct changes from the API are refused. Because Validio Code applies changes directly, an `apply` against such a namespace fails with the `DIRECT_MUTATION_IN_PROTECTED_NAMESPACE` error code (see [API errors](https://docs.validio.io/v11.0/developer/validio-api/graphql-api/api-errors.md)). Keep approval workflows off for the namespaces your Validio Code projects manage, and review your code changes in your version control system instead. Use separate namespaces for resources managed in the UI if you want to enable approval workflows for them.

## What happens if I run `apply` multiple times?

Running `apply` multiple times is fine because each run is an independent operation. Before any changes are applied, Validio compares the contents of your manifest with the contents on the server. If they contain the same configuration, no changes are made.

## What is the difference between name and resource name?

"Name" and "resource name" are effectively the same in the context of IaC. They represent a name that you give the resource, which is unique within its namespace for that type of resource, and can be used to identify a resource without looking up the generated ID.

Since every IaC object is a resource, calling it "resource name" would be redundant, so it is just called "name". This is not to be confused with the **Name** field in the GUI, which represents a display name.

## How can I move all resources from the GUI into code?

You can move all resources from any namespace into a new Validio Code project. Because all GUI resources use the `default` namespace, you can move everything from that namespace into a new or existing project.

The following example creates a new Validio Code project and moves the GUI resources into it using the `import` command:

```bash title="Bash" theme={null}
validio code init --namespace my-iac-namespace
validio code import --import-namespace default --output main.py
```

> [!NOTE]
>
> The file specified with `--output` is overwritten. Ensure that it doesn't contain code you want to keep.

## Why do I get the error "Resource \<resource\_name> already exists"?

This error happens when a resource of the same type with the same name already exists in the namespace you are applying to, for example a resource created in the Validio UI or by another Validio Code project that uses the same namespace. Resource names need to be unique within a namespace for each type of resource, because the value is used to identify an exact resource and link it to other related resources.

To avoid the error, apply the project to its own namespace. If several projects share a namespace, create a function that adds a unique prefix or suffix for each project, as shown in the following example:

```python title="Python" theme={null}
PROJECT_NAME = "my_project"

def name(resource_name: str) -> str:
    return f"{resource_name}_{PROJECT_NAME}"
```

## Can I change the name of a validator or source using IaC?

No. The name is the resource's unique identifier within its namespace and cannot be changed. Resource names are also used to link related resources together. Changing the name would be equivalent to removing the resource, creating a new resource, and then stitching together all of the relationships with the new resource.

## Why are my sources not started after I created them?

Sources cannot be started when they don't have any validators. Because new sources do not have validators, sources are not started after they're created by default. With IaC you can specify validators, but these resources are applied asynchronously, and there's no guarantee that all validators exist when the source is created.

To start your sources after applying your manifest, use the CLI:

```bash title="Bash" theme={null}
validio code apply --auto-approve && validio sources start my_source
```

## How do I import and use credentials if I don't know their secret values?

For security reasons, when you import resources into your IaC project, Validio does not expose any encrypted or sensitive data. Instead, the credential is moved and added to your manifest with the flag `ignore_changes` set to `True`. This flag ensures that the import ignores the fact that the secret value changes from its set value to an empty value in your manifest.
