Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Fields in Settings are duplicated #10540

Closed
3 tasks done
wodka opened this issue Dec 16, 2021 · 8 comments
Closed
3 tasks done

Fields in Settings are duplicated #10540

wodka opened this issue Dec 16, 2021 · 8 comments

Comments

@wodka
Copy link
Contributor

wodka commented Dec 16, 2021

Preflight Checklist

Describe the Bug

When opening the settings the fields after the first in "Branding & Style" and "Files & Storage" are multiplied

image

Info Api returns:
image

To Reproduce

unclear - same deployment does not produce this result locally.

in the fields api request there are multiple entries for the duplicated fields. Why would it create new ones there?

image

Errors Shown

there are no errors shown / and no errors in the chrome console

What version of Directus are you using?

9.2.2

What version of Node.js are you using?

16.13.1

What database are you using?

CockroachDB

What browser are you using?

Chrome

What operating system are you using?

OSX Monterey

How are you deploying Directus?

Docker

@azrikahar
Copy link
Contributor

I'm curious whether this is something that will only happen in CockroachDB (Thanks for the PR #10113 btw!) as this does look rather bizarre. Just curious, by "same deployment", do you mean both the "production" and local deployment are the exact same? Does it happen again when you redeploy it (not locally)?

That said, it would certainly qualify for as a bug with Directus if this happens to the current DBs officially supported by Directus.

@wodka
Copy link
Contributor Author

wodka commented Dec 16, 2021

with same deployment I mean that its running the same code. (I replaced the directus files in node modules with the ones from lerna build to have cockroach support with all migrations). The files are copied into a docker image to then be able to run directus start - and I'm using the same image both on the Staging as well as my local system.

Strangely enough it does not happen locally even if I start with a new database.

I'll later on try with a new database on our staging system

@azrikahar
Copy link
Contributor

(I replaced the directus files in node modules with the ones from lerna build to have cockroach support with all migrations)

Oh that makes sense. Perhaps it might be related to this after all.

Currently the system fields are located over here in form of yaml files: https://github.com/directus/directus/tree/main/api/src/database/system-data/fields

And then later on read & grabbed by the API into systemFieldRows:

for (const filepath of fieldData) {
if (filepath.includes('_defaults') || filepath.includes('index')) continue;
const systemFields = requireYAML(path.resolve(__dirname, filepath));
(systemFields.fields as FieldMeta[]).forEach((field, index) => {
const systemField = merge({ system: true }, defaults, field, {
collection: systemFields.table,
sort: index + 1,
});
// Dynamically populate auth providers field
if (systemField.collection === 'directus_users' && systemField.field === 'provider') {
getAuthProviders().forEach(({ name }) => {
systemField.options?.choices?.push({
text: formatTitle(name),
value: name,
});
});
}
systemFieldRows.push(systemField);
});
}

which then gets pushed to the array of fields in the fields API request:

fields.push(...systemFieldRows.filter((fieldMeta) => fieldMeta.collection === collection));

Maybe one way to check would be to verify whether the YAML files are somehow "built wrongly" (also not super sure how this is even possible) which may explain why it ended up adding the system fields weirdly.

@wodka
Copy link
Contributor Author

wodka commented Dec 16, 2021

mhmm :/ just trying to figure out more there. thanks for links how how this is being created - will add a few log messages in there to see what is happening on that system.

The sort has always the same number -> so the yaml files themself are ok. Even weirder is that not all fields are duplicated...

image

@wodka
Copy link
Contributor Author

wodka commented Dec 16, 2021

just realised that it is not limited to settings

image

and that all of them are repeated 18 times^^

directus_collections/group 18
directus_dashboards/user_created 18
directus_files/folder 18
directus_files/uploaded_by 18
directus_files/modified_by 18
directus_folders/parent 18
directus_notifications/recipient 18
directus_notifications/sender 18
directus_panels/dashboard 18
directus_panels/user_created 18
directus_permissions/role 18
directus_presets/user 18
directus_presets/role 18
directus_revisions/activity 18
directus_revisions/parent 18
directus_sessions/user 18
directus_settings/project_logo 18
directus_settings/public_foreground 18
directus_settings/public_background 18
directus_settings/storage_default_folder 18
directus_users/role 18

with other 195 fields only being returned only once (as they should)

@wodka
Copy link
Contributor Author

wodka commented Dec 16, 2021

HA!

it does return the relation for several entries in schema - so they actually are not identical results!

{
  "data": [
	{
	  "collection": "directus_settings",
	  "field": "project_logo",
	  "type": "uuid",
	  "schema": {
		"...": "...",
		"foreign_key_schema": "public",
		"foreign_key_table": "directus_presets",
		"foreign_key_column": "id"
	  },
	  "meta": "..."
	},
	{
	  "collection": "directus_settings",
	  "field": "project_logo",
	  "type": "uuid",
	  "schema": {
		"...": "...",
		"foreign_key_schema": "public",
		"foreign_key_table": "directus_notifications",
		"foreign_key_column": "id"
	  },
	  "meta": "..."
	},
	{
	  "collection": "directus_settings",
	  "field": "project_logo",
	  "type": "uuid",
	  "schema": {
		"...": "...",
		"foreign_key_schema": "public",
		"foreign_key_table": "directus_panels",
		"foreign_key_column": "id"
	  },
	  "meta": "..."
	},
	"..."

thinking now what might have gone wrong there... for reference Locally I'm running CRDB 21.1.10 and on the Staging System it is 21.2.10

So next for me is updating and checking if the error then starts to happen locally as well

@wodka
Copy link
Contributor Author

wodka commented Dec 16, 2021

ok, it does not make a difference - but it is showing the schema entry for every table in the database.

-> just confirmed that on the staging system for me it duplicates those fields for every table in the database. (still unclear why)

@rijkvanzanten
Copy link
Member

I'll move this to a discussion for now, as CockroachDB is technically not officially supported yet. We can move it back in here if it turns out to be a bug in Directus itself that affects the supported database vendors 👍🏻

@directus directus locked and limited conversation to collaborators Dec 16, 2021
@rijkvanzanten rijkvanzanten converted this issue into discussion #10557 Dec 16, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants