Introduce explicit type QueryLanguage = string and update code to clarify

Previously:
- There is confusion between nameWithOwner and queryLanguage.  Both are strings.
  Between

        runResult, err := codeql.RunQuery(databasePath, job.QueryLanguage, queryPackPath, tempDir)
    (agent.go l205)

  and

        func RunQuery(database string, nwo string, queryPackPath string, tempDir string) (*RunQueryResult, error)

  QueryLanguage is suddenly name with owner in the code.

  Added some debugging, the value is the query language in the two places it gets used:

        server         | 2024/07/03 18:30:15 DEBUG Processed request info location="{Data:map[bucket:packs key:1]}" language=cpp
        ...
        agent          | 2024/07/03 18:30:15 DEBUG XX: is nwo a name/owner, or the original callers' queryLanguage? nwo=cpp
        ...
        agent          | 2024/07/03 18:30:19 DEBUG XX: 2: is nwo a name/owner, or the original callers' queryLanguage? nwo=cpp

Changes:
- Introduce explicit type QueryLanguage = string and update code to clarify
- inline trivial function
This commit is contained in:
Michael Hohn
2024-07-03 13:30:02 -07:00
committed by =Michael Hohn
parent 07f93f3d27
commit b3cf7a4f65
4 changed files with 38 additions and 19 deletions

View File

@@ -27,7 +27,7 @@ func (c *CommanderSingle) startAnalyses(
analysisRepos *map[common.NameWithOwner]qldbstore.CodeQLDatabaseLocation,
queryPackLocation artifactstore.ArtifactLocation,
sessionId int,
queryLanguage string) {
queryLanguage queue.QueryLanguage) {
slog.Debug("Queueing analysis jobs", "count", len(*analysisRepos))
@@ -629,7 +629,7 @@ func (c *CommanderSingle) buildSessionInfoResponseJson(si SessionInfo) ([]byte,
Actor: actor,
ControllerRepo: controllerRepo,
ID: si.ID,
QueryLanguage: si.Language,
QueryLanguage: string(si.Language),
QueryPackURL: si.QueryPack,
CreatedAt: time.Now().Format(time.RFC3339),
UpdatedAt: time.Now().Format(time.RFC3339),
@@ -649,7 +649,7 @@ func (c *CommanderSingle) buildSessionInfoResponseJson(si SessionInfo) ([]byte,
SessionID: si.ID,
NameWithOwner: job.Spec.NameWithOwner,
}, common.JobInfo{
QueryLanguage: si.Language,
QueryLanguage: string(si.Language),
CreatedAt: response.CreatedAt,
UpdatedAt: response.UpdatedAt,
SkippedRepositories: skippedRepositories,
@@ -667,7 +667,7 @@ func (c *CommanderSingle) buildSessionInfoResponseJson(si SessionInfo) ([]byte,
}
func (c *CommanderSingle) collectRequestInfoAndSaveQueryPack(w http.ResponseWriter, r *http.Request, sessionId int) (string, []common.NameWithOwner, artifactstore.ArtifactLocation, error) {
func (c *CommanderSingle) collectRequestInfoAndSaveQueryPack(w http.ResponseWriter, r *http.Request, sessionId int) (queue.QueryLanguage, []common.NameWithOwner, artifactstore.ArtifactLocation, error) {
slog.Debug("Collecting session info")
if r.Body == nil {
@@ -708,7 +708,7 @@ func (c *CommanderSingle) collectRequestInfoAndSaveQueryPack(w http.ResponseWrit
}
// 2. Save the language
sessionLanguage := msg.Language
sessionLanguage := queue.QueryLanguage(msg.Language)
// 3. Save the repositories
var sessionRepos []common.NameWithOwner