Skip to content

Format error #1028

@fesily

Description

@fesily

Describe the bug
can not format any file

try require code_format failed when require provide.formatting,because main.lua disable require code_format

local stdRequire = require
require = function (name)
    if name == 'code_format' then
        error('cannot found code_format')
    end
    return stdRequire(name)
end

debug language-server, we can see package['provider.formatting'] type is boolean
image

script/provider/provider.lua:1036: attempt to index a boolean value (local 'pformatting')
stack traceback:
	[C]: in function 'xpcall'
	script/proto/proto.lua:184: in function <script/proto/proto.lua:159>
[Error - 10:12:26 AM] Request textDocument/formatting failed.
  Message: [10:12:26.471][error][#0]: script/provider/provider.lua:1036: attempt to index a boolean value (local 'pformatting')
stack traceback:
	[C]: in function 'xpcall'
	script/proto/proto.lua:184: in function <script/proto/proto.lua:159>

  Code: -32603 

Environment (please complete the following information):

  • OS: macOS
  • Is WSL remote? no
  • Client: VSCODE

Provide logs
file_Users_apple_apisix.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions