Error while getting .editorconfig file #9359

Closed
opened 2025-11-02 08:36:26 -06:00 by GiteaMirror · 19 comments
Owner

Originally created by @somera on GitHub (Aug 6, 2022).

Description

I found this message in /admin/notices

Error while getting .editorconfig file: normalization error: insert_final_newline=off is not an acceptable value. strconv.ParseBool: parsing "off": invalid syntax

Nothing founded in gitea.log.

Gitea Version

1.17.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

image

Git Version

2.25.1

Operating System

Ubuntu 20.04.4

How are you running Gitea?

Downloaded gitea-1.17.0-linux-amd64

Database

PostgreSQL

Originally created by @somera on GitHub (Aug 6, 2022). ### Description I found this message in /admin/notices `Error while getting .editorconfig file: normalization error: insert_final_newline=off is not an acceptable value. strconv.ParseBool: parsing "off": invalid syntax` Nothing founded in gitea.log. ### Gitea Version 1.17.0 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots ![image](https://user-images.githubusercontent.com/8334250/183264710-3e1f2184-0823-49ac-a5d4-0ab99957e65a.png) ### Git Version 2.25.1 ### Operating System Ubuntu 20.04.4 ### How are you running Gitea? Downloaded gitea-1.17.0-linux-amd64 ### Database PostgreSQL
GiteaMirror added the type/question label 2025-11-02 08:36:26 -06:00
Author
Owner

@silverwind commented on GitHub (Aug 7, 2022):

It should be true, false or unset. Best course of action is to fix the .editorconfig file. I guess it's good to see such errors somewhere instead of silently ignoring them, so I'd say it's working as intended.

@silverwind commented on GitHub (Aug 7, 2022): It should be `true`, `false` or `unset`. Best course of action is to fix the .editorconfig file. I guess it's good to see such errors somewhere instead of silently ignoring them, so I'd say it's working as intended.
Author
Owner

@somera commented on GitHub (Aug 7, 2022):

Is this an gitea internal error? Error from the update mirror task?

@somera commented on GitHub (Aug 7, 2022): Is this an gitea internal error? Error from the update mirror task?
Author
Owner

@wxiaoguang commented on GitHub (Aug 8, 2022):

It's reported by "editorconfig.Parse", which is called by SetEditorconfigIfExists when you browses the repo commits.

The problem is that you have invalid syntax in your .editorconfig

@wxiaoguang commented on GitHub (Aug 8, 2022): It's reported by "editorconfig.Parse", which is called by `SetEditorconfigIfExists` when you browses the repo commits. The problem is that you have invalid syntax in your `.editorconfig`
Author
Owner

@somera commented on GitHub (Aug 8, 2022):

It's reported by "editorconfig.Parse", which is called by SetEditorconfigIfExists when you browses the repo commits.

The problem is that you have invalid syntax in you .editorconfig

I found this: https://github.com/go-gitea/gitea/blob/main/.editorconfig

But in my gitea setup I can't find any .editorconfig.

@somera commented on GitHub (Aug 8, 2022): > It's reported by "editorconfig.Parse", which is called by `SetEditorconfigIfExists` when you browses the repo commits. > > The problem is that you have invalid syntax in you `.editorconfig` I found this: https://github.com/go-gitea/gitea/blob/main/.editorconfig But in my gitea setup I can't find any .editorconfig.
Author
Owner

@wxiaoguang commented on GitHub (Aug 8, 2022):

It's in your repository. It's a user file, committed by some user into your repository.

@wxiaoguang commented on GitHub (Aug 8, 2022): It's in your repository. It's a user file, committed by some user into your repository.
Author
Owner

@somera commented on GitHub (Aug 8, 2022):

Its in your repository. Its a user file, committed by some user into your repository.

Ach o.k. That must be one of the mirrors. In this case I can't fix it.

@somera commented on GitHub (Aug 8, 2022): > Its in your repository. Its a user file, committed by some user into your repository. Ach o.k. That must be one of the mirrors. In this case I can't fix it.
Author
Owner

@wxiaoguang commented on GitHub (Aug 8, 2022):

So maybe the proposal could be: "Make Gitea not report user's editorconfig syntax error as repository notice", or only show the syntax error on the proper page clearly.

@wxiaoguang commented on GitHub (Aug 8, 2022): So maybe the proposal could be: "Make Gitea not report user's editorconfig syntax error as repository notice", or only show the syntax error on the proper page clearly.
Author
Owner

@silverwind commented on GitHub (Aug 8, 2022):

We should probably treat values with such errors the same as unset. Maybe also show it in the repo/file view, but I think it's generall unnecessary.

@silverwind commented on GitHub (Aug 8, 2022): We should probably treat values with such errors the same as `unset`. Maybe also show it in the repo/file view, but I think it's generall unnecessary.
Author
Owner

@Gusted commented on GitHub (Aug 9, 2022):

We should probably treat values with such errors the same as unset. Maybe also show it in the repo/file view, but I think it's generall unnecessary.

Well, we can ignore the error, but you won't receive the editoconfig anymore then. As these are "hard" errors, 560dd96cab/definition.go (L53) and will just return nil as editorconfig, this library doesn't seem to have any option to change/disable this behavior either :/

@Gusted commented on GitHub (Aug 9, 2022): > We should probably treat values with such errors the same as `unset`. Maybe also show it in the repo/file view, but I think it's generall unnecessary. Well, we can ignore the error, but you won't receive the editoconfig anymore then. As these are "hard" errors, https://github.com/editorconfig/editorconfig-core-go/blob/560dd96cabfee7b13fc1e3a3cbcb23c2fcf7258b/definition.go#L53 and will just return nil as editorconfig, this library doesn't seem to have any option to change/disable this behavior either :/
Author
Owner

@silverwind commented on GitHub (Aug 9, 2022):

Best course of action would probably be to make editorconfig-core-go treat directive parsing errors the same as when the directive is absent. Could also have a editorconfig.ParseGraceful for that behaviour. Maybe @greut has an opinion.

@silverwind commented on GitHub (Aug 9, 2022): Best course of action would probably be to make `editorconfig-core-go` treat directive parsing errors the same as when the directive is absent. Could also have a `editorconfig.ParseGraceful` for that behaviour. Maybe @greut has an opinion.
Author
Owner

@greut commented on GitHub (Aug 9, 2022):

it should be easy to handle either on/off. Are those part of the spec? A graceful parsing is probably much more work...

@greut commented on GitHub (Aug 9, 2022): it should be easy to handle either `on`/`off`. Are those part of the spec? A graceful parsing is probably much more work...
Author
Owner

@silverwind commented on GitHub (Aug 9, 2022):

No, the spec only indicates true, false and unset as valid values. It does suggest graceful parsing, though:

EditorConfig plugins shall ignore unrecognized keys and invalid/unsupported values for those keys.

So while I think supporting boolean aliases like YAML does (yes, no, true, false, on, off) is probably fine, I think ultimately, invalid values should just be ignored instead of raising errors.

@silverwind commented on GitHub (Aug 9, 2022): No, [the spec](https://editorconfig-specification.readthedocs.io/) only indicates `true`, `false` and `unset` as valid values. It does suggest graceful parsing, though: > EditorConfig plugins shall ignore unrecognized keys and invalid/unsupported values for those keys. So while I think supporting boolean aliases like YAML does (yes, no, true, false, on, off) is probably fine, I think ultimately, invalid values should just be ignored instead of raising errors.
Author
Owner

@greut commented on GitHub (Aug 9, 2022):

@silverwind agreed. Most of them, could be moved to an error as log.

@greut commented on GitHub (Aug 9, 2022): @silverwind agreed. Most of them, could be moved to an error as log.
Author
Owner

@silverwind commented on GitHub (Aug 9, 2022):

On a related note, according to https://stackoverflow.com/a/57682840/808699, YAML 1.2 dropped the yes/no on/off aliases, so I think it's probably wise to follow and be strict about true/false/unset, which is also in-line with the spec.

@silverwind commented on GitHub (Aug 9, 2022): On a related note, according to https://stackoverflow.com/a/57682840/808699, YAML 1.2 dropped the yes/no on/off aliases, so I think it's probably wise to follow and be strict about true/false/unset, which is also in-line with the spec.
Author
Owner

@silverwind commented on GitHub (Aug 9, 2022):

Hmm, logging these parser "warnings" might be hard to consume. How about adding a warnings slice to a parse result, e.g.?

type Editorconfig struct {
  Root        bool
  Definitions []*Definition
  config      *Config
  warnings    []string
}

Fatal errors should still return err of course.

@silverwind commented on GitHub (Aug 9, 2022): Hmm, logging these parser "warnings" might be hard to consume. How about adding a `warnings` slice to a parse result, e.g.? ```go type Editorconfig struct { Root bool Definitions []*Definition config *Config warnings []string } ``` Fatal errors should still return `err` of course.
Author
Owner

@lunny commented on GitHub (Mar 29, 2023):

Is this still a problem?

@lunny commented on GitHub (Mar 29, 2023): Is this still a problem?
Author
Owner

@silverwind commented on GitHub (Mar 29, 2023):

Yes, https://github.com/go-gitea/gitea/pull/21257 got stalled. I think it's the right solution to parse graceful and display errors. Ideally the admin page could also show the affected repo, or the admin notice could also be removed entirely.

@silverwind commented on GitHub (Mar 29, 2023): Yes, https://github.com/go-gitea/gitea/pull/21257 got stalled. I think it's the right solution to parse graceful and display errors. Ideally the admin page could also show the affected repo, or the admin notice could also be removed entirely.
Author
Owner

@somera commented on GitHub (Apr 15, 2023):

Should this be "fixed" with 1.19.1? Cause

image

@somera commented on GitHub (Apr 15, 2023): Should this be "fixed" with 1.19.1? Cause ![image](https://user-images.githubusercontent.com/8334250/232239480-36c5c804-925f-4091-9c01-2a5ae8aefc59.png)
Author
Owner

@lunny commented on GitHub (Apr 16, 2023):

Not yet. It's only for 1.20

@lunny commented on GitHub (Apr 16, 2023): Not yet. It's only for 1.20
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9359