Assaro / DD_Bot

Discord Bot to Control Docker Services via the Docker Socket
GNU General Public License v3.0
35 stars 5 forks source link

/list command not displaying any running containers #32

Closed LCzoboriek closed 7 months ago

LCzoboriek commented 7 months ago

Hi there, im having an issue with the bot currently where the list of containers is empty on discord.

I do have an error in the logs coming up but the bot is running currently

luke@luke:~$ sudo docker container logs DD_Bot DD_Bot, Version 1.0.1 Unhandled exception. System.IO.InvalidDataException: Failed to load configuration from file '/app/settings/settings.json'. ---> System.FormatException: Could not parse the JSON file. ---> System.Text.Json.JsonReaderException: 'D' is an invalid start of a value. LineNumber: 10 | BytePositionInLine: 26. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.ParseStream(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Program.

$(String[] args) in /home/assaro/coding/dd_bot_release/src/DD_Bot.Bot/Program.cs:line 61 DD_Bot, Version 1.0.1 Unhandled exception. System.IO.InvalidDataException: Failed to load configuration from file '/app/settings/settings.json'. ---> System.FormatException: Could not parse the JSON file. ---> System.Text.Json.JsonReaderException: 'D' is an invalid start of a value. LineNumber: 10 | BytePositionInLine: 26. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.ParseStream(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Program.<Main>$(String[] args) in /home/assaro/coding/dd_bot_release/src/DD_Bot.Bot/Program.cs:line 61 DD_Bot, Version 1.0.1 Unhandled exception. System.IO.InvalidDataException: Failed to load configuration from file '/app/settings/settings.json'. ---> System.FormatException: Could not parse the JSON file. ---> System.Text.Json.JsonReaderException: '1' is an invalid start of a property name. Expected a '"'. LineNumber: 11 | BytePositionInLine: 29. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.ParseStream(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Program.
$(String[] args) in /home/assaro/coding/dd_bot_release/src/DD_Bot.Bot/Program.cs:line 61 DD_Bot, Version 1.0.1 Unhandled exception. System.IO.InvalidDataException: Failed to load configuration from file '/app/settings/settings.json'. ---> System.FormatException: Could not parse the JSON file. ---> System.Text.Json.JsonReaderException: '}' is invalid after a property name. Expected a ':'. LineNumber: 11 | BytePositionInLine: 50. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumePropertyName() at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options) at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.ParseStream(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input) at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) --- End of inner exception stack trace --- at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload) at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Program.<Main>$(String[] args) in /home/assaro/coding/dd_bot_release/src/DD_Bot.Bot/Program.cs:line 61 DD_Bot, Version 1.0.1 Info:Discord.Net v3.9.0 (API v10) Info:Connecting Info:Connected Info:Ready DockerBot: Contacting Docker Service... DockerBot: Contacting Docker Service... DD_Bot, Version 1.0.1 Info:Discord.Net v3.9.0 (API v10) Info:Connecting Info:Connected Info:Ready DockerBot: Contacting Docker Service... DockerBot: Contacting Docker Service... DD_Bot, Version 1.0.1 Info:Discord.Net v3.9.0 (API v10) Info:Connecting Info:Connected Info:Ready DD_Bot, Version 1.0.1 Info:Discord.Net v3.9.0 (API v10) Info:Connecting Info:Connected Info:Ready DockerBot: Contacting Docker Service...

It seems there is a json error, however i cant seem to identify the actual issue. If you prefer to contact over discord i have added you on there, my name is Kazak, otherwise issues tab works just as well for me

LCzoboriek commented 7 months ago
{
  "LanguageSettings": {
    "Language": "en"
  },
  "DiscordSettings": {
    "Token": "TOKENHERE",
    "AdminIDs": [
      MYIDHERE
    ],
    "UserWhitelist": false,
    "UserIDs": [
      MYIDHERE
    ],
    "UsersCanStopContainers": false,
    "AllowedContainers": [
      "DD_Bot"
    ],
    "RoleStartPermissions": {},
    "RoleStopPermissions": {},
    "UserStartPermissions": {},
    "UserStopPermissions": {}
  },
  "DockerSettings": {
    "BotName": "DD_Bot",
    "Retries": 6,
    "TimeBeforeRetry": 5,
    "ContainersPerMessage": 30
  }
}
LCzoboriek commented 7 months ago

Ah i see my issue, i had not adding quote marks around the adminid, ill close this issue

Assaro commented 7 months ago

Great to see you already fixed it. In the future i can recommend you to put the content of the json file in a text editor like Visual Studio Code or Sublimetext. They will highlight stuff like that. Might add that to the FAQ as well

LCzoboriek commented 7 months ago

Yeh i placed it in a json linting tool, but for some reason it didnt flag it up, works great though! Absolutely perfect tool for what i needed

Assaro commented 7 months ago

That is exactly what i thought when i created it. Most of my colleagues at IT school created games during project phases or made websites. However almost none of them were actually useful apart from learning new things. And so i created this.