Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 12, 2025

Problem

The JSON generator was incorrectly parsing MIME type files that contain multiple tab delimiters between the MIME type and file extensions. This is a common format in Apache's mime.types file.

For example, the line:

application/vnd.acucorp				atc acutc

Was incorrectly generating:

"acutc": "application/vnd.acucorp\t\t\t\tatc"

Instead of the correct output:

"acutc": "application/vnd.acucorp",
"atc": "application/vnd.acucorp"

This resulted in MIME type values containing tab characters and partial extension names, and missing entries for extensions that should have been parsed.

Root Cause

The bug was in the ParseMimeTypesListing method in ManagedCode.MimeTypes.Sync/Program.cs at line 148:

var parts = line.Split(' ', '\t', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);

This code appears to split on both space and tab characters, but actually uses an incorrect method signature. The Split(char, char, StringSplitOptions) overload doesn't exist - instead, this resolves to Split(char separator, int count, StringSplitOptions options) where the second char parameter is implicitly converted to an int count/limit parameter.

As a result, the split only used space as a delimiter, leaving all tab characters in the first part of the split result.

Solution

Changed to use the correct Split signature with a character array:

var parts = line.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);

This ensures both space and tab characters are properly recognized as delimiters when parsing MIME type files.

Testing

  • All 68 existing tests pass
  • Manually verified the fix correctly parses lines with multiple consecutive tabs
  • Both extensions (atc and acutc) are now correctly mapped to the same MIME type
  • MIME type values no longer contain tab characters or partial extension names

Additional Changes

  • Added *.trx to .gitignore to exclude test result files from version control

Fixes the issue reported in the original bug report referencing PR #4.

Original prompt

This section details on the original issue you should resolve

<issue_title>Issue with json generation</issue_title>
<issue_description>Here is a problem with json generator. It add extra symbols. Please check this #4

In short it was

"acutc": "application/vnd.acucorp",

But now "acutc": "application/vnd.acucorp\t\t\t\tatc",

Find and fix the issue.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #5


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 12, 2025 08:26
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
Co-authored-by: KSemenenko <4385716+KSemenenko@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with extra symbols in JSON generation Fix JSON generation bug with tab delimiters in MIME types parser Oct 12, 2025
Copilot AI requested a review from KSemenenko October 12, 2025 08:29
@KSemenenko KSemenenko marked this pull request as ready for review October 12, 2025 08:30
Copilot AI review requested due to automatic review settings October 12, 2025 08:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a critical bug in the JSON generation process where MIME type files with tab delimiters were being incorrectly parsed, resulting in malformed JSON output containing tab characters and missing extension mappings.

  • Fixed incorrect Split method usage that was treating the tab character as a count parameter instead of a delimiter
  • Changed to use proper character array syntax for splitting on both space and tab characters
  • Added *.trx to .gitignore to exclude test result files

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@KSemenenko KSemenenko merged commit 24211e8 into main Oct 12, 2025
4 checks passed
@KSemenenko KSemenenko deleted the copilot/fix-json-generation-issue branch October 12, 2025 08:31
@coveralls
Copy link

Pull Request Test Coverage Report for Build 18441468452

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 54.02%

Totals Coverage Status
Change from base Build 18431904938: 0.0%
Covered Lines: 1678
Relevant Lines: 3155

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 18441468554

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 54.02%

Totals Coverage Status
Change from base Build 18431904938: 0.0%
Covered Lines: 1678
Relevant Lines: 3155

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with json generation

3 participants